bieniu/ha-shellies-discovery-gen2

Need Assistance with configuration

Opened this issue · 1 comments

Hi, i don't understand your documentation and I am hoping we can improve it for others:

  1. I created a python_script directory and copied the repository as follows:

admin@HA:/volume1/docker/homeassistant/config/python_script$ ls -la
total 0
drwxrwxrwx+ 1 admin users 78 Nov 27 11:54 .
drwxrwxrwx+ 1 admin users 764 Nov 27 12:13 ..
drwxrwxrwx+ 1 root users 92 Nov 27 11:54 @eadir
drwxrwxrwx+ 1 admin users 312 Nov 26 01:24 ha-shellies-discovery-gen2-master
admin@HA:/volume1/docker/homeassistant/config/python_script$

  1. I added the following to the configuration.yaml file:

# Using this for autodiscovery of MQTT objects - Shelly devices
python_script:

  1. I added the following to my automations.yaml file:
  • id: shellies_announce_gen2
    alias: "Shellies Announce Gen2"
    triggers:

    • platform: homeassistant
      event: start
      variables:
      get_config_payload: "{{ {'id': 1, 'src': 'shellies_discovery', 'method': 'Shelly.GetConfig'} | to_json }}"
      get_components_payload: "{{ {'id': 1, 'src': 'shellies_discovery', 'method':'Shelly.GetComponents', 'params': {'include': ['config']}} | to_json }}"
      device_ids: # enter the list of device IDs (MQTT prefixes) here
      • shellyproem50-a0dd6ca06fcc
      • custom-prefix/em50-1
        actions:
    • repeat:
      for_each: "{{ device_ids }}"
      sequence:
      - action: mqtt.publish
      data:
      topic: "{{ repeat.item }}/rpc"
      payload: "{{ get_config_payload }}"
      - service: mqtt.publish
      data:
      topic: "{{ repeat.item }}/rpc"
      payload: "{{ get_components_payload }}"
  • id: shellies_discovery_gen2
    alias: "Shellies Discovery Gen2"
    mode: queued
    max: 999
    triggers:

    • platform: mqtt
      topic: shellies_discovery/rpc
      actions:
    • action: python_script.shellies_discovery_gen2
      data:
      id: "{{ trigger.payload_json.src }}"
      device_config: "{{ trigger.payload_json.result }}"
    • condition: template
      value_template: "{{ 'mqtt' in trigger.payload_json.result }}"
    • service: mqtt.publish
      data:
      topic: "{{ trigger.payload_json.result.mqtt.topic_prefix }}/command"
      payload: "status_update"

** When i look at the >>Settings >> Automations & Scenes >>**

I scroll down and I can see two entries

  • Shellies announce Gen2
  • Shellies discovery Gen2

I'm confused what the "device_ids:" section of the configuration is meant to look like.

This is the output from listening to the high level topic for my shelly EM50 device.
What should I be putting there from the below output??

Message 4 received on em50-1/events/rpc at 12:23 PM:
{
"src": "shellyproem50-a0dd6ca06fcc",
"dst": "em50-1/events",
"method": "NotifyStatus",
"params": {
"ts": 1732670619.81,
"em1:1": {
"id": 1,
"act_power": 0,
"aprt_power": 5,
"current": 0.02,
"freq": 50,
"pf": 0,
"voltage": 248.1
}
}
}
QoS: 0 - Retain: false
Message 3 received on em50-1/status/em1:1 at 12:23 PM:
{
"id": 1,
"current": 0.02,
"voltage": 247.6,
"act_power": 0,
"aprt_power": 5,
"pf": 0,
"freq": 50,
"calibration": "factory"
}
QoS: 0 - Retain: false
Message 2 received on em50-1/status/em1:0 at 12:23 PM:
{
"id": 0,
"current": 0.02,
"voltage": 247.6,
"act_power": 1,
"aprt_power": 5,
"pf": 0,
"freq": 50,
"calibration": "factory"
}
QoS: 0 - Retain: false
Message 1 received on em50-1/events/rpc at 12:23 PM:
{
"src": "shellyproem50-a0dd6ca06fcc",
"dst": "em50-1/events",
"method": "NotifyStatus",
"params": {
"ts": 1732670620.8,
"em1:0": {
"id": 0,
"act_power": 1,
"aprt_power": 5,
"current": 0.02,
"freq": 50,
"pf": 0,
"voltage": 247.6
}
}
}
QoS: 0 - Retain: false
Message 0 received on em50-1/online at 12:23 PM:
true
QoS: 0 - Retain: true

  1. When i run the script from the automations section, the following error is reported

Logger: homeassistant.components.automation.shellies_discovery_gen2
Source: helpers/script.py:2026
integration: Automation (documentation, issues)
First occurred: 11:52:47 AM (15 occurrences)
Last logged: 12:13:45 PM

Shellies Discovery Gen2: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'payload_json'
Shellies Discovery Gen2: Error executing script. Service not found for call_service at pos 1: Action python_script.shellies_discovery_gen2 not found

Please complete the issue form.

  1. I created a python_script directory and copied the repository as follows:

The documentation does not state that you need to clone the repository.

I'm confused what the "device_ids:" section of the configuration is meant to look like.

device_ids: # enter the list of device IDs (MQTT prefixes) here. Look at the MQTT section in the device webpanel.