All Projects → bieniu → Ha Shellies Discovery

bieniu / Ha Shellies Discovery

Licence: apache-2.0
Script that adds MQTT discovery support for Shellies devices

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ha Shellies Discovery

Esp Mqtt Json Digital Leds
(OBSOLETE) ESP8266 MQTT JSON Digital LEDs for Home Assistant
Stars: ✭ 503 (+345.13%)
Mutual labels:  home-assistant, mqtt
Open Home
Projeto de automação residencial usando softwares e hardwares open source.
Stars: ✭ 41 (-63.72%)
Mutual labels:  home-assistant, mqtt
Hassio Zigbee2mqtt
Hass.io add-on for zigbee2mqtt
Stars: ✭ 547 (+384.07%)
Mutual labels:  home-assistant, mqtt
Homeassistant
Home Assistant Configuration Files and Documentation
Stars: ✭ 395 (+249.56%)
Mutual labels:  home-assistant, mqtt
Pysmartnode
Micropython Smarthome framework
Stars: ✭ 58 (-48.67%)
Mutual labels:  home-assistant, mqtt
Miflora Mqtt Daemon
Linux service to collect and transfer Xiaomi Mi Flora plant sensor data via MQTT to your smart home system, with cluster support 🌱🌼🥀🏡🌳
Stars: ✭ 409 (+261.95%)
Mutual labels:  home-assistant, mqtt
Smarthome
SmartHome: firmware per ESP8266 - Casa domotica
Stars: ✭ 28 (-75.22%)
Mutual labels:  home-assistant, mqtt
Heatpump
Arduino library to control Mitsubishi Heat Pumps via connector cn105
Stars: ✭ 327 (+189.38%)
Mutual labels:  home-assistant, mqtt
Addon Zwave2mqtt
Z-Wave to MQTT - Home Assistant Community Add-ons
Stars: ✭ 58 (-48.67%)
Mutual labels:  home-assistant, mqtt
Homeautomation.codesys3
Home Automation system build in CoDeSys 3 with MQTT communication to any third party Home Automation software
Stars: ✭ 55 (-51.33%)
Mutual labels:  home-assistant, mqtt
Tdm
GUI application to discover and monitor devices flashed with https://github.com/arendst/Sonoff-Tasmota
Stars: ✭ 385 (+240.71%)
Mutual labels:  discovery, mqtt
Home Assistant Configuration
My Home Assistant Config. For more Information visit ->
Stars: ✭ 102 (-9.73%)
Mutual labels:  home-assistant, mqtt
Zigbee2mqttassistant
GUI for Zigbee2Mqtt running in docker and HASS.IO
Stars: ✭ 371 (+228.32%)
Mutual labels:  home-assistant, mqtt
Smarthome
@skalavala 👍 Nothing But Smarthome Stuff! - By Mahasri Kalavala
Stars: ✭ 437 (+286.73%)
Mutual labels:  home-assistant, mqtt
Harmony Api
🗼 A simple server allowing you to query/control multiple local Harmony Home Hubs over HTTP or MQTT
Stars: ✭ 345 (+205.31%)
Mutual labels:  home-assistant, mqtt
Open Home Automation
Open Home Automation with Home Assistant, ESP8266/ESP32 and MQTT
Stars: ✭ 820 (+625.66%)
Mutual labels:  home-assistant, mqtt
Awesome Home Assistant
A curated list of amazingly awesome Home Assistant resources.
Stars: ✭ 3,487 (+2985.84%)
Mutual labels:  home-assistant, mqtt
Esphome
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Stars: ✭ 4,324 (+3726.55%)
Mutual labels:  home-assistant, mqtt
Wavin Ahc 9000 Mqtt
Esp8266 mqtt interface for Wavin AHC-9000/Jablotron AC-116
Stars: ✭ 47 (-58.41%)
Mutual labels:  home-assistant, mqtt
Frigate
NVR with realtime local object detection for IP cameras
Stars: ✭ 1,329 (+1076.11%)
Mutual labels:  home-assistant, mqtt

Shellies Discovery

GitHub Release GitHub All Releases hacs_badge Community Forum Buy me a coffee PayPal_Me

Screenshot

This script adds MQTT discovery support for Shelly devices in the Home Assistant.

Prerequisites

This script needs Home Assistant python_script component so, if you never used it, I strongly suggest you to follow the official instruction and check that python_script is properly configured and it's working.

Installation

You can download shellies_discovery.py file and save it in <config>/python_scripts folder or install the script via HACS. You won't find Shellies Discovery in the HACS Integrations section, nor add it as a custom repository. You must have a properly configured python_script component to be able to install the script from the HACS Automations section.

After installing the script and adding automations, run Shellies Announce automation or restart Home Assistant twice.

Go to HA community for support and help.

Supported devices

  • Shelly 1 (with external sensors and external switch)
  • Shelly 1L (with external sensors)
  • Shelly 1PM (with external sensors)
  • Shelly 2 (relays and roller mode)
  • Shelly 2.5 (relays and roller mode)
  • Shelly 3EM
  • Shelly 4Pro
  • Shelly Air
  • Shelly Bulb
  • Shelly Bulb RGBW
  • Shelly Button1 (battery or USB powered)
  • Shelly Dimmer
  • Shelly Dimmer 2
  • Shelly Door/Window
  • Shelly Door/Window 2
  • Shelly DUO
  • Shelly EM
  • Shelly Flood
  • Shelly Gas
  • Shelly H&T (battery or USB powered)
  • Shelly i3
  • Shelly Motion (battery or USB powered)
  • Shelly Plug
  • Shelly Plug S
  • Shelly Plug US
  • Shelly RGBW2 (color and white mode)
  • Shelly Sense (battery or USB powered)
  • Shelly Smoke
  • Shelly UNI (with external sensors)
  • Shelly Vintage

How to debug

To debug the script add this to your logger configuration:

# configuration.yaml file
logger:
  default: warning
  logs:
    homeassistant.components.python_script: debug
    homeassistant.components.automation: info

Troubleshooting checklist

  • correct MQTT configuration in Home Assistant with discovery enabled
  • same discovery_prefix in Home Assistant configuration and in script configuration
  • Shellies firmware updated to current version
  • Home Assistant updated to current version
  • enabled MQTT in Shellies configuration
  • you can't manually run the shellies_discovery.py script ('trigger' is undefined error)

Shelly device name

The script supports Shelly devices with non-standard names (Internet & Security -> Advanced - developer settings -> Custom MQTT prefix in the Shelly WWW panel). If you want to change the name of the Shelly device, you must first remove the device from Home Assistant (Configuration -> Integrations -> MQTT -> Device -> Remove). Otherwise, all device entities will be duplicated.

Minimal configuration

# configuration.yaml file
python_script:

# automations.yaml file
- id: shellies_announce
  alias: 'Shellies Announce'
  trigger:
    - platform: homeassistant
      event: start
    - platform: time_pattern
      hours: "/1"  # Modifying this if you are using Shelly Motion can drain your device's battery quickly.
  action:
    service: mqtt.publish
    data:
      topic: shellies/command
      payload: announce

- id: 'shellies_discovery'
  alias: 'Shellies Discovery'
  mode: queued
  max: 999
  trigger:
    platform: mqtt
    topic: shellies/announce
  action:
    service: python_script.shellies_discovery
    data:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      model: '{{ trigger.payload_json.model }}'
      mode: '{{ trigger.payload_json.mode }}'

Custom configuration example

# configuration.yaml file
python_script:

# automations.yaml file
- id: shellies_announce
  alias: 'Shellies Announce'
  trigger:
    - platform: homeassistant
      event: start
    - platform: time_pattern
      hours: "/1"  # Modifying this if you are using Shelly Motion can drain your device's battery quickly.
  action:
    service: mqtt.publish
    data:
      topic: shellies/command
      payload: announce

- id: 'shellies_discovery'
  alias: 'Shellies Discovery'
  mode: queued
  max: 999
  trigger:
    platform: mqtt
    topic: shellies/announce
  action:
    service: python_script.shellies_discovery
    data:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      model: '{{ trigger.payload_json.model }}'
      mode: '{{ trigger.payload_json.mode }}'
      discovery_prefix: 'hass'
      qos: 2
      shelly1-AABB9900:
        relay-0: "light"
        ext-temperature-0: true
        ext-temperature-1: true
        ext-temperature-2: true
        force_update_sensors: true
        ext-switch: true
      shelly1pm-aabb9911:
        ext-temperature-0: true
        ext-humidity-0: true
        push_off_delay: false
        force_update_sensors: true
      shelly1l-ddbb9911:
        ext-temperature-0: true
        ext-temperature-1: true
        ext-temperature-2: true
        ext-humidity-0: true
      shellyswitch-123409FF:
        relay-0: "fan"
        relay-0-name: "Bathroom Fan"
        relay-1: "light"
        relay-1-name: "Livingroom Light"
      shellyswitch-123409cc:
        relay-1: "fan"
      shellydimmer-883409cc:
        light-0-name: "Bedroom Lamp"
      shellyswitch25-334455AA:
        mode: "roller"
        roller-0-name: "Garage"
        roller-0-class: "garage"
      shellyplug-s-CCBBCCAA:
        relay-0: "light"
        force_update_sensors: true
      shellyht-11AA00CCDD:
        force_update_sensors: true
        expire_after: 500
      shellyht-11AA00CCEE:
        powered: "battery"
      shellyht-11AA00CCFF:
        powered: "ac"
      shellyswitch2-AA4455AA:
        mode: "roller"
        position_template: "{{ '{% if value | float < 30 %}0{% else %}{{ value }}{% endif %}' }}"
        set_position_template: "{{ '{%if position | float < 30 %}0{% else %}{{ position }}{% endif %}' }}"
      shellybutton1-112200CCFF:
        powered: "ac"
      shellymotionsensor-113300CCFF:
        powered: "ac"
      shellyrgbw2-AA123FF32:
        light-1-name: "Living room"
        light-2-name: "Bedroom"
        light-3-name: "Kitchen"
      shellyem-BB23CC45:
        force_update_sensors: true
      ignored_devices:
        - shelly1-DD0011
        - shellyem-EECC22

Battery powered devices

For battery powered devices, the script requires you to set the value of 12h for sleep_mode.period or to configure expire_after yourself.

Don't send announce topic more than once an hour if you're using Shelly Motion! This can quickly drain your device's battery.

How to use device automation triggers?

device_automation

Script arguments

key optional type default description
discovery_prefix True string homeassistant MQTT discovery prefix
qos True integer 0 MQTT QoS, you can use 0, 1 or 2
ignored_devices True list None list of devices to ignore
ignore_device_model True boolean false ignore device model to generate device name

Device arguments

key optional type default possible values description
relay-<NUM> True string switch switch, light, fan component to use with the relay number NUM
relay-<NUM>-name True string None string friendly name of the relay number NUM
roller-<NUM>-name True string None string friendly name of the roller number NUM
roller-<NUM>-class True string None string device_class of the roller number NUM
light-<NUM>-name True string None string friendly name of the light number NUM
ext-temperature-<NUM> True boolean false true, false presence of temperature sensor number NUM
ext-humidity-<NUM> True boolean false true, false presence of humidity sensor number NUM
ext-switch True boolean false true, false presence of external switch
force_update_sensors True boolean false true, false force update for sensors
push_off_delay True boolean true true, false off delay (2 sec) for longpush/shortpush/double shortpush/triple shortpush binary sensors
mode True string relay, roller relay or roller for Shelly 2/Shelly 2.5
powered True string battery ac, battery ac or battery powered for Shelly H&T, Motion, Sense and Button1
expire_after True integer 51840 expire after for battery powered sensors in seconds
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].