#works for me, added you as friend here,

1 messages · Page 1 of 1 (latest)

narrow nimbus
#

@covert marsh

#

Post the sensors you have

covert marsh
#

Hi. I have a Shelly 4 Pro PM

narrow nimbus
#

what's the topic?

#

and you just want the 4 relays?

#

MQTT topic

covert marsh
#

Let me run down to my PC

narrow nimbus
#

Well anyways, Assuming that you want what's listed in that blog...

covert marsh
#

You wanna do a screenshare?

narrow nimbus
#

I'll just write it out here

covert marsh
#

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.

narrow nimbus
#

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

covert marsh
#

folder , yes

narrow nimbus
#

add

mqtt: !include_dir_merge_list mqtt

to configuration.yaml

#

this points the MQTT integration to that folder

covert marsh
#

will this break my zigbee2mqtt setup?

narrow nimbus
#

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?

covert marsh
#

let me check

#

miedzyzdroje/shellypro4pm-84cca87fe874

narrow nimbus
#

so when you browse to that location, it has a relay inner portion?

#

are you using MQTT explorer?

covert marsh
#

yes

narrow nimbus
#

ok, are you on a windows computer?

covert marsh
#

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

narrow nimbus
#

yeah I get all that, I need to see something

#

so, do you have teamviewer setup on whatever you'

#

're using MQTT exploerer on?

covert marsh
#

i do

narrow nimbus
#

you have an ID and pw?

covert marsh
#

can we share via pn instead of public...? 😉

narrow nimbus
#

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

covert marsh
#

yep

narrow nimbus
#

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?

covert marsh
#

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
narrow nimbus
#

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

covert marsh
#

it should be the "output":true

narrow nimbus
#

alright and what about the on/off command

covert marsh
#

trying out...

narrow nimbus
#

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

covert marsh
#

does this help?

narrow nimbus
#

well that's the pro

#

not the propm

#

and your topics look completely different

#

you don't have a relays section at all

narrow nimbus
#

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' }}
covert marsh
#

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

narrow nimbus
#

you just need to copy/paste that whole chunk 3 more times, and increment the switch:0 to switch:1 after each one.