chrisdaloa icon

Shelly's script

chrisdaloa | PRO | 01/27/19 05:15:54 PM UTC | 0 ⭐ | 490 👁️ | Never ⏰ | []
YAML |

2.85 KB

|

None

|

0 👍

/

0 👎

# Shelly1 in Home Assistant as relay with entity registry support
# You can use switch, light or fan component with this configuration
switch:
  - platform: mqtt
    name: 'Shelly1 XXXXXX'
    state_topic: 'shellies/shelly1-XXXXXX/relay/0'
    command_topic: 'shellies/shelly1-XXXXXX/relay/0/command'
    availability_topic: 'shellies/shelly1-XXXXXX/online'
    unique_id: 'shelly1-XXXXXX-relay-0'
    payload_on: 'on'
    payload_off: 'off'
    payload_available: 'true'
    payload_not_available: 'false'
    qos: 1
    retain: true
 
# Shelly2 in Home Assistant as relay with entity registry support
# You can use switch, light or fan component with this configuration
switch:
  - platform: mqtt
    name: 'Shelly2 YYYYYY Relay 0'
    state_topic: 'shellies/shellyswitch-YYYYYY/relay/0'
    command_topic: 'shellies/shellyswitch-YYYYYY/relay/0/command'
    availability_topic: 'shellies/shellyswitch-YYYYYY/online'
    unique_id: 'shellyswitch-YYYYYY-relay-0'
    payload_on: 'on'
    payload_off: 'off'
    payload_available: 'true'
    payload_not_available: 'false'
    qos: 1
    retain: true
 
  - platform: mqtt
    name: 'Shelly2 YYYYYY Relay 1'
    state_topic: 'shellies/shellyswitch-YYYYYY/relay/1'
    command_topic: 'shellies/shellyswitch-YYYYYY/relay/1/command'
    availability_topic: 'shellies/shellyswitch-YYYYYY/online'
    unique_id: 'shellyswitch-YYYYYY-relay-1'
    payload_on: 'on'
    payload_off: 'off'
    payload_available: 'true'
    payload_not_available: 'false'
    qos: 1
    retain: true
 
# This automation rule is responsible for the availability of Shellies on the Home Assistant start
automation:
  - id: shellies_announce
    alias: 'Shellies Announce'
    trigger:
      - platform: homeassistant
        event: start
    action:
      service: mqtt.publish
      data:
        topic: shellies/command
        payload: announce
 
# Sensors for energy (in kWh) and power (in W) for Shelly2 with entity registry support
sensor:
  - platform: mqtt
    name: 'Shelly2 YYYYYY Power'
    state_topic: 'shellies/shellyswitch-YYYYYY/relay/power'
    value_template: '{{ value | float | round(0) }}'
    unit_of_measurement: 'W'
    unique_id: 'shellyswitch-YYYYYY-relay-power'
 
  - platform: mqtt
    name: 'Shelly2 YYYYYY Energy'
    state_topic: 'shellies/shellyswitch-YYYYYY/relay/energy'
    unit_of_measurement: 'kWh'
    value_template: '{{ ((value | float) / 100) | round(2) }}'
    unique_id: 'shellyswitch-YYYYYY-relay-energy'
 
# Sensor with current firmware version
sensor:
  - platform: rest
    resource: 'http://<SHELLY IP>/status
    name: 'Shelly Firmware Version Current'
    value_template: "{{ (value_json['update'].new_version).split('/')[1].split('@')[0] | replace('v', '') }}"
    authentication: basic
    username: '<Shelly login>'
    password: '<Shelly password>'
    scan_interval: 7200

Comments