mauog
(Mauro)
December 27, 2022, 8:29pm
1
Hi,
I realised that Shelly plus 2 PM uses different MQTT messages/topics compared to older Shelly 2.5 or Shelly 1.
I’m using it as a cover control. I tried to figure out what these new topics are but I cannot understand how to open/close the cover.
Up to now I just got that
mqtt:
cover:
- name: "tapparella_cucina1"
unique_id: "shellyplus2pm-xxx"
availability:
topic: "shellies/shellyplus2pm-xxx/online"
payload_available: "true"
state_topic: "shellies/shellyplus2pm-xxx/status/cover:0"
value_template: "{{ value_json.state }}"
state_open: "open"
state_closed: "close"
position_topic: "shellies/shellyplus2pm-xxx/status/cover:0"
value_template: "{{ value_json.current_pos }}"
position_open: 100
position_closed: 0
command_topic: "shellies/shellyplus2pm-xxx/events/rpc"
How can I send open/close command? How can I set a specific position?
Thanks
2 Likes
mauog
(Mauro)
December 27, 2022, 9:08pm
2
I looked into this issue.
I found this link where I found some useful mqtt topic.
To send commands to the device it is needed to send them to <shelly-id>/rpc
Commands are messages described here for the cover.
So I changed my config:
mqtt:
cover:
- name: "tapparella_cucina1"
unique_id: "shellyplus2pm-xxx"
availability:
topic: "shellies/shellyplus2pm-xxx/online"
payload_available: "true"
state_topic: "shellies/shellyplus2pm-xxx/status/cover:0"
value_template: "{{ value_json.state }}"
state_open: "open"
state_closed: "close"
position_topic: "shellies/shellyplus2pm-xxx/status/cover:0"
value_template: "{{ value_json.current_pos }}"
position_open: 100
position_closed: 0
command_topic: "shellies/shellyplus2pm-xxx/rpc"
payload_open: '{"id":0,"method":"Cover.Open","params":{"id":0}}'
payload_close: '{"id":0,"method":"Cover.Close","params":{"id":0}}'
But nothing happens when I push on the arrows in HA user Interface to open/close the cover.
Comman is correctly sento to mqtt server I can see it with an mqtt explorer but the shelly looks not to read it.
Any idea?
Thanks
mauog
(Mauro)
December 30, 2022, 5:35pm
3
The Shelly documentation is a little bit confused.
I managed to command the cover now.
The json payload must contain also a “src” field:
payload_open: '{"id":0,"src":"admin","method":"Cover.Open","params":{"id":0}}'
payload_close: '{"id":0,"src":"admin","method":"Cover.Close","params":{"id":0}}'
This fixed the problem
Moreover to have the position working it is needed to have an integer in position_template value:
position_topic: "shellies/shellyplus2pm-xxx/status/cover:0"
position_template: "{{ value_json.current_pos | int }}"
1 Like
daflipz
(Philipp)
April 10, 2023, 6:33pm
4
Hi, thanks for sharing your config and solution but also your “solution” doesn’t work for me. I used your config an the HA and Shelly documentations as well as some “subscripe” and “publish” tests with the Mqtt.fx tool to put in some extensions. Now it ist possibile to control the cover with the following functions: open, close, stop, and the go to position.
Config-File: /config/mqtt.yaml
cover:
- name: "Cover XXXXXXXXXX"
unique_id: "shellyplus2pm-XXXXXXXXXX"
availability_topic: "shellyplus2pm-XXXXXXXXXX/online"
payload_available: "true"
payload_not_available: "false"
state_topic: "shellyplus2pm-XXXXXXXXXX/status/cover:0"
value_template: "{{ value_json.state }}"
state_opening: "opening"
state_closing: "closing"
state_stopped: "stopped"
state_open: "open"
state_closed: "closed"
position_topic: "shellyplus2pm-XXXXXXXXXX/status/cover:0"
position_template: "{{ value_json.current_pos | int }}"
position_open: 100
position_closed: 0
command_topic: "shellyplus2pm-XXXXXXXXXX/rpc"
payload_open: '{"id":0,"src":"shellyplus2pm-XXXXXXXXXX","method":"Cover.Open","params":{"id":0}}'
payload_close: '{"id":0,"src":"shellyplus2pm-XXXXXXXXXX","method":"Cover.Close","params":{"id":0}}'
payload_stop: '{"id":0,"src":"shellyplus2pm-XXXXXXXXXX","method":"Cover.Stop","params":{"id":0}}'
set_position_topic: "shellyplus2pm-XXXXXXXXXX/rpc"
set_position_template: '{"id":0,"src":"shellyplus2pm-XXXXXXXXXX","method":"Cover.GoToPosition","params":{"id":0,"pos":{{ position }}}}'
For me this works fine to control my covers over mqtt with the shelly 2 pm plus
2 Likes
newneo
(Neo)
December 25, 2023, 10:20am
6
Thank you! works very well!
works 1 to 1 like shelly integrations control.
Another question is how can you get the sensor data via mqtt power, energy, device temperature… etc.?
aperezva
(Aperezva)
May 8, 2024, 6:20am
7
Its not working to me, I can open and close the cover but onlt with position service. It´s not working close and open command
Any advice ?