Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSQUITTO BROKER - allow support for Lua-Based Mosquitto Plugin #3919

Open
puterboy opened this issue Feb 9, 2025 · 2 comments
Open

MOSQUITTO BROKER - allow support for Lua-Based Mosquitto Plugin #3919

puterboy opened this issue Feb 9, 2025 · 2 comments

Comments

@puterboy
Copy link

puterboy commented Feb 9, 2025

Describe the issue you are experiencing

(Note that I initially posted this request to the "Community Forum" but the moderators helpfully suggested that I post here instead.)

I would like to be able to filter out invalid MQTT messages at the Mosquitto broker level.

For example, my temperature sensors which involve 4 entities (temperature, humidity, RSSI, batter) often get invalid data which I can detect by humidity > 100.

I would like to filter these out wholesale at the broker level by doing something like:

function acl_check(clientid, username, topic, payload, qos, retain)
    local json = require("cjson")  -- Make sure Lua JSON library is available
    local data = json.decode(payload)
    
    -- Reject if "humidity" exists and is greater than 100
    if data.humidity and tonumber(data.humidity) > 100 then
        return mosq.AUTH_DENIED
    end
    
    return mosq.AUTH_GRANTED
end

And then modifying mosquitto.conf by adding:

plugin /usr/lib/mosquitto/auth_plugin.so
auth_plugin /etc/mosquitto/auth_filter.lua

My understanding is that this is not possible currently since you can't add plugins to the add-on.

Is that correct?
If so, is there any way to add the plugin capability to the broker add-on?

What type of installation are you running?

Home Assistant OS

Which operating system are you running on?

Home Assistant Operating System

Which add-on are you reporting an issue with?

Mosquitto broker

What is the version of the add-on?

6.5.0

Steps to reproduce the issue

As above

System Health information

NA

Anything in the Supervisor logs that might be useful for us?

Anything in the add-on logs that might be useful for us?

Additional information

No response

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 11, 2025
@puterboy
Copy link
Author

Please keep open. Thanks.

@github-actions github-actions bot removed the stale label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant