I’ve recently bought a Shelly 2.5 switch and this is how I’ve setup my Home Assistant. Here is my configuration.yaml for the switches. I’m controlling lights as a result I’m using the lights objects
I use the Home Assistant add-on named mosquitto as MQTT for everything so I can keep the communication system the same for all my devices and keep the management system simple.
First of all I configured my Shelly 2.5 thru the web interface to use MQTT. This is done in the “Internet & Security” configuration settings, “Advance Developer – Settings”.
I configured the username and password that was set in Mosquitto MQTT server in Home Assistant. Don’t forget the IP address of the Home Assistant server (port 1883).
I’ve used a custom MQTT prefix as you can see in the yaml files configuration below. I use this prefix as a way to give a name to my switch
# lights
light:
- platform: mqtt
unique_id: luz_sala_jantar_tecto
name: "Luz do tecto da sala de jantar"
state_topic: "shellies/sala_tecto/relay/0"
command_topic: "shellies/sala_tecto/relay/0/command"
payload_on: 'on'
payload_off: 'off'
retain: false
qos: 1
- platform: mqtt
unique_id: luz_sala_estar_tecto
name: "Luz do tecto da sala de estar"
state_topic: "shellies/sala_tecto/relay/1"
command_topic: "shellies/sala_tecto/relay/1/command"
payload_on: 'on'
payload_off: 'off'
retain: false
qos: 1
The Shelly 2.5 has temperature sensor so I’ve configured it like this
sensor:
- platform: mqtt
unique_id: sensor_temperatura_sala_tecto
name: "Temperatura da luz do tecto da sala"
state_topic: "shellies/sala_tecto/temperature"
unit_of_measurement: 'ºC'
There is a power sensor so check the configuration here
sensor:
- platform: mqtt
unique_id: sensor_potencia_sala_jantar_tecto
name: "Potência da luz do tecto da sala de jantar"
state_topic: "shellies/sala_tecto/relay/0/power"
unit_of_measurement: 'W'
And for the energy sensor, this is the way I’ve set it up.
sensor
- platform: mqtt
unique_id: sensor_energia_sala_jantar_tecto
name: "Energia da luz do tecto da sala de jantar"
state_topic: "shellies/sala_tecto/relay/0/energy"
unit_of_measurement: 'Wh'
And I’ve used a binary sensor for the the temperature alert.
binary_sensor:
- platform: mqtt
unique_id: alerta_temperatura_luz_sala_tecto
name: "Alerta de temperatura da luz do tecto da sala"
state_topic: "shellies/sala_tecto/overtemperature"
device_class: "heat"
payload_off: "0"
payload_on: "1"
If you want you can check the Shelly 2.5 specification here at the official Selly website.
And I’m a Mauser.pt store fan so go check the site.