Jan P. Posted March 12 Posted March 12 Hello, I am having an awful time figuring out how to control my Shelly Plus1PM with mosquitto_pub. I have tried to adapt what was written in a different forum post here to no avail. What I have so far is the messages that I can see subscribing to the MQTT broker as follows when I switch it on and off via Home Assistant: mosquitto_sub -v -h 10.200.0.8 -u user -P pass -p 1883 -t '#' | grep shellyplus1pm shellyplus1pm-7c87ce735d94/online true shellyplus1pm-7c87ce735d94/events/rpc {"src":"shellyplus1pm-7c87ce735d94","dst":"shellyplus1pm-7c87ce735d94/events","method":"NotifyStatus","params":{"ts":1710242564.60,"switch:0":{"id":0,"output":true,"source":"WS_in"}}} shellyplus1pm-7c87ce735d94/events/rpc {"src":"shellyplus1pm-7c87ce735d94","dst":"shellyplus1pm-7c87ce735d94/events","method":"NotifyStatus","params":{"ts":1710242565.71,"switch:0":{"id":0,"apower":2922.9}}} shellyplus1pm-7c87ce735d94/events/rpc {"src":"shellyplus1pm-7c87ce735d94","dst":"shellyplus1pm-7c87ce735d94/events","method":"NotifyStatus","params":{"ts":1710242565.71,"switch:0":{"id":0,"current":12.316}}} shellyplus1pm-7c87ce735d94/events/rpc {"src":"shellyplus1pm-7c87ce735d94","dst":"shellyplus1pm-7c87ce735d94/events","method":"NotifyStatus","params":{"ts":1710242571.08,"switch:0":{"id":0,"apower":0,"current":0,"output":false,"source":"WS_in"}}} shellyplus1pm-7c87ce735d94/events/rpc {"src":"shellyplus1pm-7c87ce735d94","dst":"shellyplus1pm-7c87ce735d94/events","method":"NotifyStatus","params":{"ts":1710242580.00,"switch:0":{"id":0,"aenergy":{"by_minute":[4854.780,0.000,0.000],"minute_ts":1710242580,"total":94693.900}}}} shellyplus1pm-7c87ce735d94 matches the settings in the mqtt web gui of the Plu1PM. Can someone based on the above figure out what I have to type on a Linux shell and mosquitto_pub or the line to use with mosquitto_pub in a bash script to switch the relay on and off or toggle it ? Any help is greatly appreciated. Jan P. Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish
Moderators terae Posted April 7 Moderators Posted April 7 Did you already figure out it? This is way to turn on/off relays (in example first one, starts from 0) mosquitto_pub -u "$user" -P "$pass" -h localhost -t "$id"/rpc -m '{"id": 1, "src": "whatever", "method":"Switch.Set", "params":{"id":0,"on":true} }' mosquitto_pub -u "$user" -P "$pass" -h localhost -t "$id"/rpc -m '{"id": 1, "src": "justsomething", "method":"Switch.Set", "params":{"id":0,"on":false} }' same with all gen2 except switch-addon to Pro 3EM which is relay 100. So like this mosquitto_pub -h 10.200.0.8 -u user -P pass -p 1883 -t shellyplus1pm-7c87ce735d94/rpc -m '{"id": 123, "src": "whocares", "method":"Switch.Set", "params":{"id":0,"on":true} }' Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.