#works for me, added you as friend here,
1 messages · Page 1 of 1 (latest)
Hi. I have a Shelly 4 Pro PM
Let me run down to my PC
Well anyways, Assuming that you want what's listed in that blog...
You wanna do a screenshare?
I'll just write it out here
OK. So the SHelly 4 Pro has Switches Power meters and binary sensors. I am trying to have them as entities in HASS. The Broker is receiving data already. I just need to understand how to set the entities up.
you'd set them up via YAML
create a folder named mqtt in your config folder
or if you want, you can just create a single file named mqtt.yaml
choice is yours
but you have to tell me what you did
I'll just assume you're going with the folder
folder , yes
add
mqtt: !include_dir_merge_list mqtt
to configuration.yaml
this points the MQTT integration to that folder
will this break my zigbee2mqtt setup?
no
next create an emtpy yaml file in the mqtt folder, name it whatever you want. I'd do something like shelly_4_pro.yaml
what's the device ID for this?
so when you browse to that location, it has a relay inner portion?
are you using MQTT explorer?
yes
ok, are you on a windows computer?
miedzyzdroje/shellypro4pm-84cca87fe874/status/switch:0
{"id":0, "source":"init", "output":true, "apower":0.0, "voltage":239.1, "freq":50.0, "current":0.000, "pf":0.00, "aenergy":{"total":71198.969,"by_minute":[0.000,0.000,0.102],"minute_ts":1699474199},"temperature":{"tC":42.9, "tF":109.2}}
yeah I get all that, I need to see something
so, do you have teamviewer setup on whatever you'
're using MQTT exploerer on?
i do
you have an ID and pw?
can we share via pn instead of public...? 😉
k
@covert marsh I see you've already provided me w/ the info I need here. Give me a moment
{
"id": 0,
"source": "init",
"output": true,
"apower": 0,
"voltage": 239.1,
"freq": 50,
"current": 0,
"pf": 0,
"aenergy": {
"total": 71198.969,
"by_minute": [
0,
0,
0.102
],
"minute_ts": 1699474199
},
"temperature": {
"tC": 42.9,
"tF": 109.2
}
}
sorry, just using this as a placeholder
@covert marsh here
yep
the switch topic
which represents the switch itself?
the on/off
and do you know the command topic to turn the switch on and off?
that one Blog says it should be along the lines of:
/switches/din/shelly_4pro.yaml
- platform: mqtt
name: "4Pro - Channel 1"
expire_after: 604800
qos: 1
command_topic: "shellies/shelly4pro-<deviceid>/relay/0/command"
payload_on: "on"
payload_off: "off"
state_topic: "shellies/shelly4pro-<deviceid>/relay/0"Remove the line below if the value_template doesn't function properly
value_template: {{ 'on' if value == 'on' else 'off' }} # Test for capturing 'overpower' state
yeah, but that's completely incorrect based on your topic
pretty much everything about that is incorrect based on what you've shared
right now, I can create both the power & energy readings
w/o needing any other info
the switch, we'd need to know the command topic to turn it on/off and we'd need to know what value represents the switch being on
it should be the "output":true
alright and what about the on/off command
trying out...
Here's your 2 sensors, you can paste this into your file
- sensor:
name: "4Pro - Channel 1 - Power"
unique_id: "4Pro - Channel 1 - Power"
unit_of_measurement: 'W'
expire_after: 86400
device_class: power
state_class: measurement
qos: 1
state_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/status/switch:0"
value_template: "{{ value_json.apower }}"
- sensor:
name: "4Pro - Channel 1 - Energy"
unique_id: "4Pro - Channel 1 - Energy"
unit_of_measurement: 'kWh'
expire_after: 86400
device_class: energy
state_class: total_increasing
qos: 1
state_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/status/switch:0"
value_template: "{{ value_json.aenergy.total / 60000 }}"
So all that's left is your switches
well that's the pro
not the propm
and your topics look completely different
you don't have a relays section at all
it does help
- switch:
name: "4Pro - Relay 1"
unique_id: "4Pro - Relay 1"
expire_after: 604800
qos: 1
command_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/command/switch:0"
payload_on: "on"
payload_off: "off"
state_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/status/switch:0"
value_template: {{ 'on' if value_json.output else 'off' }}
that should be the relay
all together for 1 switch that should go inside the shelly_4_pro_pm.yaml file (or whatever you named it):
- sensor:
name: "4Pro - Channel 1 - Power"
unique_id: "4Pro - Channel 1 - Power"
unit_of_measurement: 'W'
expire_after: 86400
device_class: power
state_class: measurement
qos: 1
state_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/status/switch:0"
value_template: "{{ value_json.apower }}"
- sensor:
name: "4Pro - Channel 1 - Energy"
unique_id: "4Pro - Channel 1 - Energy"
unit_of_measurement: 'kWh'
expire_after: 86400
device_class: energy
state_class: total_increasing
qos: 1
state_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/status/switch:0"
value_template: "{{ value_json.aenergy.total / 60000 }}"
- switch:
name: "4Pro - Relay 1"
unique_id: "4Pro - Relay 1"
expire_after: 604800
qos: 1
command_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/command/switch:0"
payload_on: "on"
payload_off: "off"
state_topic: "miedzyzdroje/shellypro4pm-84cca87fe874/status/switch:0"
value_template: {{ 'on' if value_json.output else 'off' }}
Error loading /config/configuration.yaml: while parsing a flow mapping
in "/config/mqtt/shelly_4_pro.yaml", line 30, column 22
expected ',' or '}', but got '<scalar>'
in "/config/mqtt/shelly_4_pro.yaml", line 30, column 29
you just need to copy/paste that whole chunk 3 more times, and increment the switch:0 to switch:1 after each one.