I have shelly switch and I have the sonoff pow r2 switch. I want to add an option for my home assistant to notifty me about update of the firmware of the switches. Is there an option to do so in home assistant? How can I do it?
Not sure for your specific options but I use this for my Sonoff switches with Tasmota…
sensor:
# Tasmota Firmware
# Getting Firmware from JSON for Tasmota
- platform: rest
resource: https://api.github.com/repos/arendst/Sonoff-Tasmota/releases/latest
name: Sonoff Firmware Version Available
username: !secret githubuser
password: !secret githubpass
authentication: basic
value_template: '{{ value_json.tag_name }}'
headers:
Accept: application/vnd.github.v3+json
Content-Type: application/json
User-Agent: Home Assistant REST sensor
- platform: mqtt
name: "Coffee Maker Firmware"
state_topic: "sonoff1/stat/STATUS2"
value_template: 'v{{ value_json.StatusFWR.Version | replace("(sonoff)", "") | replace("(release-sonoff)", "") }}'
- platform: mqtt
name: "Toothbrush Firmware"
state_topic: "sonoff2/stat/STATUS2"
value_template: 'v{{ value_json.StatusFWR.Version | replace("(sonoff)", "") | replace("(release-sonoff)", "") }}'
- platform: mqtt
name: "Garage Door Firmware"
state_topic: "sonoff5/stat/STATUS2"
value_template: 'v{{ value_json.StatusFWR.Version | replace("(sonoff)", "") | replace("(release-sonoff)", "") }}'
- platform: mqtt
name: "Alarm Firmware"
state_topic: "sonoff6/stat/STATUS2"
value_template: 'v{{ value_json.StatusFWR.Version | replace("(sonoff)", "") | replace("(release-sonoff)", "") }}'
- platform: mqtt
name: "Nodemcu Lounge Firmware"
state_topic: "nodemcu_lounge/stat/STATUS2"
value_template: 'v{{ value_json.StatusFWR.Version | replace("(sonoff)", "") | replace("(release-sonoff)", "") }}'
binary_sensor:
- platform: template
sensors:
sonoff_update_available:
value_template: >-
{{ (states('sensor.sonoff_firmware_version_available') > states('sensor.toothbrush_firmware')) or (states('sensor.sonoff_firmware_version_available') > states('sensor.coffee_maker_firmware')) or (states('sensor.sonoff_firmware_version_available') > states('sensor.garage_door_firmware')) or (states('sensor.sonoff_firmware_version_available') > states('sensor.alarm_firmware'))
}}
This code I put in the configuration.yaml file?
Yep… you’ll need to mod it for your entity_id’s but yes it’s from config yaml. (In the sensor: section)
what is the sensor: section in the config?
Above the original code I posted you need this:
sensor:
I edited it above as well.
Are you using the stock firmware for the Shelly’s & Sonoff’s?
For shelly I am using the stock firmware. for Sonoff I flashed tasmota because with the stock firmware I can’t use it with home assistant.
Ok I added this code to configurtaion.yaml. now in the main page there are 3 circles in the top of the page: “sonoff update available”, “sonoff firmware version available” , “boiler switch firmware”. in the state topic of the code should I write like you or like I wrote to config the switch? to config the switch I wrote: state_topic: “stat/sonoff/POWER”. Is there a way to check this?
I am using MQTT Discovery which changes the order in the topic so if you don’t use discovery then use stat/sonoff/STATUS2 instead of what I have shown.
Thank you! How can I check if it’s working?