New plugin: MQTT for PSUControl

I run Zigbee2MQTT and some Zigbee socket like Philips HUE but by using MQTT as interface, I can use whatever I want thru my HomeSeer4 or Node-Red system.

I see, that's not a setup I've seen/heard of before. If you fancy a small bit of Python coding, creating a PSU Control sub-plugin is quite simple. There's nothing that's already built that will help you to connect to that system, but you should be able to look at the existing subplugins for inspiration?

Hi @SveinHa. @Charlie_Powell already said the most important things correctly. I will still add some (redundant) information:

The plugin is meant to work if your switch is already controllable by PSU control plugin in any way. It then makes the switch controllable by via mqtt.

BUT: If your switch is already listening and acting on mqtt topics on its own you can select the appropriate topics in the plugin options and control it via the psu control UI. There is one problem though: it will not detect the current state of the switch because It's not really how both of these plugins are meant to work.

I think (haven't tried) this OctoPrint-TasmotaMQTT plugin could do what you need on its own. It says tasmota, but mqtt should be mqtt.

Thanks @oerkel47 , I'll look into it, the "tasmota" part of it put it out of my radar :relieved:

Yeah MQTT is MQTT, true but the problem is my TasmotaMQTT plugin puts in other bits specific to Tasmota firmware for status and on/off commands, so will probably not work in your use case since you aren't running Tasmota firmware. You could however fork the plugin, adjust those MQTT paths as necessary, etc.

I've been looking at the code and it is quite extensive for my simple head... I noted that to turn power on, the Tasmota command is "POWER1=ON" and, to my surprise, that works for my HUE. Official HUE command is "{"state":"on"}". But from here it stops because Tasmota is waiting for feedback that the power really is on.

Yeah, that's why I mentioned it. It really wouldn't be too difficult to implement sub plugin with configurable topics/status responses. I'm just not looking to support another plugin I wouldn't use personally.

I just created a PSU Control subplugin for MQTT:
I tested it on my lamp but some more feedback is appreciated.

You have to download from github and do a manual install because it's not yet in the official repo.

If it goes on the official repo, we are definitely going to need some differentiation between the two...

Do you think it could be done within the same plugin? Or is that more complex?

I don't know. The new one is a small subplugin for PSU Control while the first one has to run in "parallel" to PSU Control to achieve its goal. I don't think combining is a good idea.

The problem is when people don't read the readme on github :stuck_out_tongue:
The new one PSUControl-MQTT is pretty straight forward with its name. It's two different usecases both containing MQTT and PSUControl..It's confusing yes. If renaming MQTT for PSUControl to something more specific is an option, I would see this as a possibility.

Nice :+1: Works like a charm with these settings:

The response from my HUE socket is this:

{
"linkquality": 255,
"state": "OFF",
"update": {
"state": "idle"
},
"update_available": false
}

I guess the "Switch state topic" should be "get" instead of "set" but I still get no feedback. No big deaL...

Nice, thanks for testing. I will add some more settings to be able to use it with different kinds of reading the state.

1 Like

Hey, can you please try my new version from github? It has some more settings which should now work with devices that want to be queried before they send out their current state.

If I understand the documentation from zigbee2mqtt for philips hue correctly, settings should be like this:

Not sure what trigger reading of the state but with my HUE socket ON and rebooting OctoPrint the state is indicated as OFF (grey lightning)

Does that mean it works before reboot? Can you set logging to debug for the plugin and post some logs to pastebin? I think that would clear everything up.Thanks.

Didn't quite know how to upload log file and file too large to attatch here so I created an issue. Shortly before the end of the file, I shut off power from the plugin and turned on from elsewhere without status change in the lightning icon

Thanks, I see. It appears there are no incoming messages from MQTT.
Could it be you have sensing not configured or set to internal in PSU Control?

Also, can you please re-check if the options are set correctly? According to the log it sends "ON" and "OFF" instead of {"state": "xxx"} what you did before.

These settings also works so I just let them be (default values)

Sensing was not set up, my mistake. In "MQTT Explorer", I see that the query message is sent at the specified interval (5 sec) but something don't add up making the status change... Posting new logfiles in a sec...

Thanks for all the feedback, the new log helps a lot. Hopefully, next version will work :wink:

1 Like