Jump to content

Recommended Posts

Posted

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.

  • 4 weeks later...
  • Moderators
Posted

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} }'

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...