Code Monkey home page Code Monkey logo

ha-shellies-discovery-gen2's Introduction

Shellies Discovery Gen2

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

โš ๏ธ WARNING

Firmware 0.12.x and 0.13.x don't support consumption type for relays.

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

image

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.

For the device to work with the script, it must have MQTT configured and options RPC status notifications over MQTT and Generic status update over MQTT enabled.

Installation

You can download shellies_discovery_gen2.py file and save it in <config>/python_scripts folder or install the script via HACS. You won't find Shellies Discovery Gen2 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.

Shellies Discovery Gen2 will automatically install/update the script on your Shelly device. Due to python_scripts integration limitations, updating the device script requires the announce automation to run twice.

Supported devices

  • Shelly Plus 1
  • Shelly Plus 1PM
  • Shelly Plus 2PM
  • Shelly Plus Add-on
  • Shelly Plus H&T
  • Shelly Plus I4
  • Shelly Plus Plug IT
  • Shelly Plus Plug S
  • Shelly Plus Plug UK
  • Shelly Plus Plug US
  • Shelly Plus Smoke
  • Shelly Plus Wall Dimmer
  • Shelly Pro 1
  • Shelly Pro 1PM
  • Shelly Pro 2
  • Shelly Pro 2PM
  • Shelly Pro 3
  • Shelly Pro 3EM
  • Shelly Pro 4PM
  • Shelly Pro EM
  • Shelly Wall Display

Battery powered devices

Battery powered devices like Plus H&T are put to sleep most of the time. For this reason, adding/updating entities configuration for a device should be done as follows:

  • enter the device into setup mode (press the button on the device)
  • manually run Shellies Announce Gen2 automation

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

Supported platforms

  • binary sensor
  • button
  • fan
  • light
  • sensor
  • switch
  • update

Supported features

  • the device name is taken from the device configuration
  • the relay name is taken from the device configuration
  • the relay consumption type is taken from the device configuration (consumption type must contain light or fan to configure light or fan platform)
  • if the input type is set to button, device automation triggers are available
  • custom MQTT prefixes are supported

Script arguments

key optional type default description
discovery_prefix True string homeassistant MQTT discovery prefix
script_prefix True string MQTT prefix to install the script in the device
qos True integer 0 MQTT QoS, you can use 0, 1 or 2

Configuration

# configuration.yaml file
python_script:

# automations.yaml file
- id: shellies_announce_gen2
  alias: "Shellies Announce Gen2"
  trigger:
    - platform: homeassistant
      event: start
  variables:
    device_info_payload:  "{{ {'id': 1, 'src':'shellies_discovery', 'method':'Shelly.GetConfig'} | to_json }}"
    device_ids:  # enter the list of device IDs (MQTT prefixes) here
      - shellyplus2pm-485519a1ff8c
      - custom-prefix/shelly-kitchen
  action:
    - repeat:
        for_each: "{{ device_ids }}"
        sequence:
          - service: mqtt.publish
            data:
              topic: "{{ repeat.item }}/rpc"
              payload: "{{ device_info_payload }}"

- id: shellies_discovery_gen2
  alias: "Shellies Discovery Gen2"
  mode: queued
  max: 999
  trigger:
  - platform: mqtt
    topic: shellies_discovery/rpc
  action:
  - service: python_script.shellies_discovery_gen2
    data:
      id: "{{ trigger.payload_json.src }}"
      device_config: "{{ trigger.payload_json.result }}"

ha-shellies-discovery-gen2's People

Contributors

bieniu avatar dependabot[bot] avatar github-actions[bot] avatar maciejmajewski avatar bakkerrs avatar roopesh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.