Shellies Discovery Script

Script uses exactly those topics in roller mode. What is the problem?

Sorry to bother with a beginnerā€™s question.

I added the python_script to configuration.yaml

GNU nano 4.6                   configuration.yaml                             
# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

#Shelly component
python_script:



I added the minimal to the automation.yaml as follows:

GNU nano 4.6                    automations.yaml                               
automation:
  - id: shellies_announce
    alias: 'Shellies Announce'
    trigger:
      - platform: homeassistant
        event: start
    action:
      service: mqtt.publish
      data:
        topic: shellies/command
        payload: announce

  - id: 'shellies_discovery'
    alias: 'Shellies Discovery'
    trigger:
      - platform: mqtt
        topic: shellies/announce
    action:
      service: python_script.shellies_discovery
      data_template:
        id: '{{ trigger.payload_json.id }}'
        mac: '{{ trigger.payload_json.mac }}'
        fw_ver: '{{ trigger.payload_json.fw_ver }}'

I must be doing something wrong, for this gives me errors in the log:

Invalid config for [automation]: [automation] is an invalid option for [automation]. Check: automation->automation. (See /config/configuration.yaml, line 13).

12:46 PM components/hassio/__init__.py (ERROR) - message first occurred at 12:45 PM and shows up 2 times

Error loading /config/configuration.yaml: expected '<document start>', but found '<block sequence start>' in "/config/automations.yaml", line 2, column 3

12:46 PM components/hassio/__init__.py (ERROR)

expected '<document start>', but found '<block sequence start>' in "/config/automations.yaml", line 2, column 3

12:46 PM util/yaml/loader.py (ERROR)

Surely this is because I donā€™t know whatā€™s going on, but I could use a step by step here.

Remove automation: from automations.yaml file. Learn how to use yaml :wink:

Well, you have no idea on how much I need to learn before I get comfortable. :wink:

Is there a step by step on how to configure?
The overview now shows indeed shellies discovery and shellies announce, but am totally lost on how to get my H&T showing up as a device.

Both of them connect to the MQTT Mosquitto broker, but thatā€™s all. Iā€™ve been reading through the comments above, and I still donā€™t know what to do next. In any case, I canā€™t get the devices to show up automatically.

New version: 0.14.1

Changelog:

  • change ID split method

New version: 0.15.0

Changelog:

  • add support for external temperature sensors (Shelly1 and Shelly1PM)
  • add debugging logs
  • better errors handling

Configuration example for external sensors:

  - id: 'shellies_discovery'
    alias: 'Shellies Discovery'
    trigger:
      - platform: mqtt
        topic: shellies/announce
    action:
      service: python_script.shellies_discovery
      data_template:
        id: '{{ trigger.payload_json.id }}'
        mac: '{{ trigger.payload_json.mac }}'
        fw_ver: '{{ trigger.payload_json.fw_ver }}'
        shelly1-001122-ext-0: 'temperature'
        shelly1-001122-ext-1: 'temperature'
        shelly1-001122-ext-2: 'temperature'

If HA and Shelly H&T are correct configured to connect to MQTT broker and automations (Shellies Announce and Shellies Discovery) are enabled You have to push the button on H&T. After that Shellies Discovery script will do the rest and entities will show up in Configuration -> Integrations -> MQTT.

I knew it would be a simple thing to doā€¦

Thanks a lot!

1 Like

Is it possible that the offset of the Shelly H&T is not sent over through the script?

My shelly needs to be offset for both temp and humidity. And on the IP of the shelly the humidity is spot on with the offset, but the output to the HA is not quite correct.

Is there a way to work around this?

Script has no effect on the values that device sends.

Ok, thanks for the reply.

Just fyi, on the Shelly H&T there is an offset (both humidity and temperature) you need to ā€˜calibrateā€™ in order that the devices have the correct value. That offset is clearly not pulled into the HA.

Looking at this thread, it appears that this is not unusual. If you look at the IP-of-shelly/status then you get the ā€˜corrected valuesā€™. If you look at HA you get the ā€˜baseā€™ values. Would you think that it could pull the ā€˜corrected valuesā€™ or would that be to complex to get into the script?

No. Script only sends to broker config topics for MQTT discovery. Nothing more. If device sends incorrect values via MQTT those values will be show in HA. Check what H&T sends via MQTT. If values are incorrect ask about that Shelly support.

Question about Shelly 1ā€™s and the script.

I have a Shelly 1 hooked up to my garage door opener that I want to use in some Node-Red jobs. However, the script found it and labelled it as a switch. Is there a way short of going the manual route to have it be a cover instead of a switch?

Thanks.

There's a bug in the script:
lines 382 and 383 should have:

    position_topic = f"{state_topic}/pos"
    set_position_topic = f"{state_topic}/command/pos"

Can someone correct this?

New version: 0.15.1

Changelog:

  • fix topics in roller_mode
  • add total and total_returned sensors for ShellyEM

New version: 0.15.2

Changelog:

  • fix units for total and total_returned sensors (ShellyEM)

Good job @Bieniu, you should be granted every shelly unit to keep your script up-to-date :slight_smile:

1 Like

Thanks. You can suggest this on the Shelly group on FB :smiley:

Iā€™m facing the following situation:

  • I need to put in floorplan the IDs of the entities in the svg file
  • if Iā€™m changing the Shelly units, I will need to edit again the svg file

Would it be possible to include in your script the ability to change the entity name, just as you change the type (light, switch, fan) ?

Theoretically yes but it would require a lot of work. You can change friendly name and entity ID via entity registry.