]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Added Shelly Sensors, added Shelly Reboot script, minor additional changes
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 16 Dec 2019 11:00:30 +0000 (12:00 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 16 Dec 2019 11:00:30 +0000 (12:00 +0100)
12 files changed:
automation/shelly.yaml [new file with mode: 0644]
customizations/shelly.yaml
group/shelly.yaml [new file with mode: 0644]
history.yaml
light/sala.yaml
logbook.yaml
recorder.yaml
script/shelly.yaml
sensor/shelly.yaml [new file with mode: 0644]
shell_command/shelly.yaml
shell_scripts/shelly_reboot.sh [new file with mode: 0755]
ui-lovelace.yaml

diff --git a/automation/shelly.yaml b/automation/shelly.yaml
new file mode 100644 (file)
index 0000000..2db456c
--- /dev/null
@@ -0,0 +1,19 @@
+######################################################################
+# Shelly: Update Available Notifications
+######################################################################
+
+- alias: "Shelly: Notifica aggiornamento"
+  initial_state: 'on'
+
+  trigger:
+    - platform: state
+      entity_id: group.shelly
+      to: 'on'
+
+  action:
+    service: script.notify_text
+    data_template:
+      title: "Shelly - Aggiornamento"
+      message: "Sono disponibili aggiornamenti per i dispositivi Shelly"
+      enable_persistant: true
+
index 17603c23a99b48ad941f2f018eb3b0a946dd9490..d4f3adf167ec7eae62a2804490f67c74fb3d693b 100644 (file)
@@ -4,3 +4,5 @@
 
 script.shelly_upgrade:
   icon: mdi:cellphone-arrow-down
+script.shelly_reboot:
+  icon: mdi:restart
diff --git a/group/shelly.yaml b/group/shelly.yaml
new file mode 100644 (file)
index 0000000..dcb4995
--- /dev/null
@@ -0,0 +1,21 @@
+######################################################################
+# Group Shelly Devices
+######################################################################
+
+shelly:
+  name: Shelly Devices
+  view: true
+  #icon: mdi:thermometer
+  entities:
+    - sensor.shelly1_status
+    - sensor.shelly2_status
+    - sensor.shelly3_status
+    - sensor.shelly4_status
+    - sensor.shelly5_status
+    - sensor.shelly6_status
+    - sensor.shelly7_status
+    - sensor.shelly8_status
+    - sensor.shelly9_status
+    - sensor.shellybulb_status
+    - sensor.shellyem_status
+    - sensor.shellyplugs_status
index d6ce8cd7556c340195fbf00e2d5be0bebea790db..57ead76d745c2ee4f8bb3c84dadb75ecb90f456a 100644 (file)
@@ -23,6 +23,7 @@ exclude:
     - binary_sensor.ff590mr_park_brake_status
     - binary_sensor.ff590mr_tire_warning
     - binary_sensor.ff590mr_trunk
+    - binary_sensor.ff590mr_fuel_lid
     #- binary_sensor.ff590mr_warning_brakefluid
     #- binary_sensor.ff590mr_warning_coolantlevellow
     #- binary_sensor.ff590mr_warning_washwater
@@ -49,6 +50,19 @@ exclude:
     - sensor.ff590mr_tire_pressure_rear_left
     - sensor.ff590mr_tire_pressure_rear_right
     - sensor.ff590mr_trunk
+    # Shelly
+    - sensor.shelly1_status
+    - sensor.shelly2_status
+    - sensor.shelly3_status
+    - sensor.shelly4_status
+    - sensor.shelly5_status
+    - sensor.shelly6_status
+    - sensor.shelly7_status
+    - sensor.shelly8_status
+    - sensor.shelly9_status
+    - sensor.shellybulb_status
+    - sensor.shellyem_status
+    - sensor.shellyplugs_status
     # Energy Sensors
     - sensor.potenza_reattiva
     - sensor.tensione
index 436ec19f7404e330e7a7d7a5a1314c2d17544431..f22477dcf23ec77decf92fff5bf1b08df9634b3f 100644 (file)
 # Living Room Light (White)
 ######################################################################
 
-- platform: mqtt
-  name: Luce Divano Bianca
-  schema: template
-  command_topic: "shellies/shellybulb-BC8610/color/0/set"
-  state_topic: "shellies/shellybulb-BC8610/color/0/status"
-  command_on_template: >
-    {
-      "turn": "on",
-      "mode": "white",
-      {%- if color_temp is defined -%}
-        "temp": {{ (1000000/(((float(color_temp)-153)/354*180)+153)-35) | int }},
-      {%- endif -%}
-      {%- if brightness is defined -%}
-        "brightness": {{ (brightness/255*100) | int }},
-      {%- endif -%}
-      "effect": 0
-    }
-  command_off_template: >
-    {
-      "turn": "off",
-      "mode": "white",
-      "effect": 0
-    }  
-  state_template: >
-    {% if value_json.ison == true and value_json.mode == "white" %}
-      on
-    {% else %}
-      off
-    {% endif %}
-  brightness_template: '{{ (value_json.brightness/100*255)|int }}'
-  color_temp_template: "{{ (1000000/(((float(value_json.temp)-3000)/3500*4500)+2000)) | int }}"
-  retain: false
-  qos: 0
-  optimistic: false
+#- platform: mqtt
+#  name: Luce Divano Bianca
+#  schema: template
+#  command_topic: "shellies/shellybulb-BC8610/color/0/set"
+#  state_topic: "shellies/shellybulb-BC8610/color/0/status"
+#  command_on_template: >
+#    {
+#      "turn": "on",
+#      "mode": "white",
+#      {%- if color_temp is defined -%}
+#        "temp": {{ (1000000/(((float(color_temp)-153)/354*180)+153)-35) | int }},
+#      {%- endif -%}
+#      {%- if brightness is defined -%}
+#        "brightness": {{ (brightness/255*100) | int }},
+#      {%- endif -%}
+#      "effect": 0
+#    }
+#  command_off_template: >
+#    {
+#      "turn": "off",
+#      "mode": "white",
+#      "effect": 0
+#    }  
+#  state_template: >
+#    {% if value_json.ison == true and value_json.mode == "white" %}
+#      on
+#    {% else %}
+#      off
+#    {% endif %}
+#  brightness_template: '{{ (value_json.brightness/100*255)|int }}'
+#  color_temp_template: "{{ (1000000/(((float(value_json.temp)-3000)/3500*4500)+2000)) | int }}"
+#  retain: false
+#  qos: 0
+#  optimistic: false
 
 ######################################################################
 # Living Room Global
index b0d151f9187ddff2d44811ba2754e8f4d01b22ac..1ba78d586758d766b37feed56f6436ec926ad806 100644 (file)
@@ -23,6 +23,7 @@ exclude:
     - binary_sensor.ff590mr_park_brake_status
     - binary_sensor.ff590mr_tire_warning
     - binary_sensor.ff590mr_trunk
+    - binary_sensor.ff590mr_fuel_lid
     #- binary_sensor.ff590mr_warning_brakefluid
     #- binary_sensor.ff590mr_warning_coolantlevellow
     #- binary_sensor.ff590mr_warning_washwater
@@ -49,6 +50,19 @@ exclude:
     - sensor.ff590mr_tire_pressure_rear_left
     - sensor.ff590mr_tire_pressure_rear_right
     - sensor.ff590mr_trunk
+    # Shelly
+    - sensor.shelly1_status
+    - sensor.shelly2_status
+    - sensor.shelly3_status
+    - sensor.shelly4_status
+    - sensor.shelly5_status
+    - sensor.shelly6_status
+    - sensor.shelly7_status
+    - sensor.shelly8_status
+    - sensor.shelly9_status
+    - sensor.shellybulb_status
+    - sensor.shellyem_status
+    - sensor.shellyplugs_status
     # Energy Sensors
     - sensor.potenza_reattiva
     - sensor.tensione
index 06a13923d4e329411c49bee82e327505a7e78768..ec1490e2b9bb36cbd64435ffd25bc1cb33ccc856 100644 (file)
@@ -25,6 +25,7 @@ exclude:
     - binary_sensor.ff590mr_park_brake_status
     - binary_sensor.ff590mr_tire_warning
     - binary_sensor.ff590mr_trunk
+    - binary_sensor.ff590mr_fuel_lid
     #- binary_sensor.ff590mr_warning_brakefluid
     #- binary_sensor.ff590mr_warning_coolantlevellow
     #- binary_sensor.ff590mr_warning_washwater
@@ -51,6 +52,19 @@ exclude:
     - sensor.ff590mr_tire_pressure_rear_left
     - sensor.ff590mr_tire_pressure_rear_right
     - sensor.ff590mr_trunk
+    # Shelly
+    - sensor.shelly1_status
+    - sensor.shelly2_status
+    - sensor.shelly3_status
+    - sensor.shelly4_status
+    - sensor.shelly5_status
+    - sensor.shelly6_status
+    - sensor.shelly7_status
+    - sensor.shelly8_status
+    - sensor.shelly9_status
+    - sensor.shellybulb_status
+    - sensor.shellyem_status
+    - sensor.shellyplugs_status
     # Energy Sensors
     - sensor.potenza_reattiva
     - sensor.tensione
index ec5aa03548488cb92090a8a4d34e57796eb11c00..1518dfde8aac6e2cfa6f341a2637c2341e52cdb5 100644 (file)
@@ -77,3 +77,12 @@ shelly_upgrade:
       data:
         topic: 'shellies/shellyplug-s-7A31CB/command'
         payload: 'update_fw'
+
+######################################################################
+# Shelly: Reboot
+# - shell_command.shelly_reboot
+######################################################################
+shelly_reboot:
+  alias: "Shelly: Riavvia Dispositivi"
+  sequence:
+    - service: shell_command.shelly_reboot
diff --git a/sensor/shelly.yaml b/sensor/shelly.yaml
new file mode 100644 (file)
index 0000000..17947ec
--- /dev/null
@@ -0,0 +1,335 @@
+######################################################################
+# Sensor: Shelly 1
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly1.giorgioravera.it/status
+  method: GET
+  name: shelly1_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 2
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly2.giorgioravera.it/status
+  method: GET
+  name: shelly2_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 3
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly3.giorgioravera.it/status
+  method: GET
+  name: shelly3_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 4
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly4.giorgioravera.it/status
+  method: GET
+  name: shelly4_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 5
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly5.giorgioravera.it/status
+  method: GET
+  name: shelly5_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 6
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly6.giorgioravera.it/status
+  method: GET
+  name: shelly6_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 7
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly7.giorgioravera.it/status
+  method: GET
+  name: shelly7_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 8
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly8.giorgioravera.it/status
+  method: GET
+  name: shelly8_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly 9
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shelly9.giorgioravera.it/status
+  method: GET
+  name: shelly9_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly Bulb
+######################################################################
+
+#- platform: rest
+#  scan_interval: 43200
+#  resource: http://shellybulb.giorgioravera.it/status
+#  method: GET
+#  name: shellybulb_status
+#  #value_template: '{{ value_json.has_update }}'
+#  value_template: >-
+#    {% if value_json.has_update == True %}
+#      on
+#    {% else %}
+#      off
+#    {% endif %}
+#  authentication: basic
+#  username: !secret shelly_user
+#  password: !secret shelly_password
+#  json_attributes:
+#  #  - wifi_sta
+#  #  - mqtt
+#  #  - time
+#  #  - has_update
+#    - mac
+#    - update
+#    - uptime
+
+######################################################################
+# Sensor: Shelly EM
+######################################################################
+
+- platform: rest
+  scan_interval: 43200
+  resource: http://shellyem.giorgioravera.it/status
+  method: GET
+  name: shellyem_status
+  #value_template: '{{ value_json.has_update }}'
+  value_template: >-
+    {% if value_json.has_update == True %}
+      on
+    {% else %}
+      off
+    {% endif %}
+  authentication: basic
+  username: !secret shelly_user
+  password: !secret shelly_password
+  json_attributes:
+  #  - wifi_sta
+  #  - mqtt
+  #  - time
+  #  - has_update
+    - mac
+    - update
+    - uptime
+
+######################################################################
+# Sensor: Shelly Plug S
+######################################################################
+
+#- platform: rest
+#  scan_interval: 43200
+#  resource: http://shellyplugs.giorgioravera.it/status
+#  method: GET
+#  name: shellyplugs_status
+#  #value_template: '{{ value_json.has_update }}'
+#  value_template: >-
+#    {% if value_json.has_update == True %}
+#      on
+#    {% else %}
+#      off
+#    {% endif %}
+#  authentication: basic
+#  username: !secret shelly_user
+#  password: !secret shelly_password
+#  json_attributes:
+#  #  - wifi_sta
+#  #  - mqtt
+#  #  - time
+#  #  - has_update
+#    - mac
+#    - update
+#    - uptime
index 56b2867a0098366dac1059835b35e46391a5097c..229e12c13affafa55949978d841e136eec355ac8 100644 (file)
@@ -1 +1,2 @@
 shelly_upgrade: 'bash /var/lib/homeassistant/.homeassistant/shell_scripts/shelly_upgrade.sh'
+shelly_reboot: 'bash /var/lib/homeassistant/.homeassistant/shell_scripts/shelly_reboot.sh'
diff --git a/shell_scripts/shelly_reboot.sh b/shell_scripts/shelly_reboot.sh
new file mode 100755 (executable)
index 0000000..2be5768
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+HASS_HOME="/var/lib/homeassistant/.homeassistant"
+USER=$(awk '/shelly_user/ { print  $2 }' $HASS_HOME/secrets.yaml)
+PASSWORD=$(awk '/shelly_password/ { print  $2 }' $HASS_HOME/secrets.yaml)
+SHELLY_ID=(
+       shelly1.giorgioravera.it
+       shelly2.giorgioravera.it
+       shelly3.giorgioravera.it
+       shelly4.giorgioravera.it
+       shelly5.giorgioravera.it
+       shelly6.giorgioravera.it
+       shelly7.giorgioravera.it
+       shelly8.giorgioravera.it
+       shelly9.giorgioravera.it
+       shellybulb.giorgioravera.it
+       shellyem.giorgioravera.it
+       shellyplugs.giorgioravera.it
+)
+
+echo "Reboot Shelly Devices"
+
+for i in "${SHELLY_ID[@]}"
+do
+       ALIVE=$(ping -c 1 $i |grep ttl)
+       if [ ! -z "$ALIVE" ]; then
+               STATUS=$(curl -s --user $USER:$PASSWORD http://$i/reboot | sed -e "s/{"ok"}://g")
+               echo $STATUS
+       fi
+done
+
+echo "Done"
index 027001ed2e17da8d277a935ad488465a19d0497a..d47c30ebef60c324c093313c2c7d20fc78f0d613 100644 (file)
@@ -51,7 +51,7 @@ views:
       #entity: group.lights_livingroom
       entities: 
       - light.luce_divano
-      - light.luce_divano_bianca
+      #- light.luce_divano_bianca
       - cover.tapparella_sala
       - climate.sala_termostato_sala
       - media_player.tv_sala
@@ -157,7 +157,7 @@ views:
         - light.luce_corridoio
         - light.luci_sala
         - light.luce_divano
-        - light.luce_divano_bianca
+        #- light.luce_divano_bianca
         - light.luci_bagno
         - light.luce_bagno
         - light.luce_specchio
@@ -184,9 +184,9 @@ views:
       name: Luce Divano
       entity: light.luce_divano
 
-    - type: light
-      name: Luce Divano Bianca
-      entity: light.luce_divano_bianca
+#    - type: light
+#      name: Luce Divano Bianca
+#      entity: light.luce_divano_bianca
 
     - type: light
       name: Luci Bagno
@@ -1425,19 +1425,13 @@ views:
 #                entity_id: script.homeassistant_upgrade
 
         - type: horizontal-stack
-          cards:          
+          cards:
           - type: entities
             title: Operazione sui Dispositivi
             show_header_toggle: false
             entities:
             - script.shelly_upgrade
-#          - type: entity-button
-#            entity: script.shelly_upgrade
-#            tap_action:
-#              action: call-service
-#              service: script.turn_on
-#              service_data:
-#                entity_id: script.shelly_upgrade
+            - script.shelly_reboot
 
       - type: vertical-stack
         cards: