I’ve been using the amazon Dash buttons with DASSHIO for quite a while now and they work excellently. However I thought I would like to make my own version:-
Requirements:
ESP01 module — £1.18
AMS1117 power regulator – £0.15
Momentary switch —£0.02
‘Poundland’ power bank (18650 1200mA rechargeable battery) — £1
I used the code from here, MQTT window sensor :-
[https://www.youtube.com/watch?v=BoYVr2UwWWg&t=167s 1st video
https://www.youtube.com/watch?v=2kLZ7DlP9KU&t=77s 2nd video
https://www.youtube.com/channel/UC2gyzKcHbYfqoXA5xbyGXtQ The Hooked UP channel
And replaced the reed switch for a miniature momentary switch.
Put the whole lot inside the ‘power bank’ (ESP01 fits perfectly) and then added some code into HASSIO to interact via MQTT.
Configuration.yaml
## WIFI IOT Button
- platform: mqtt
name: "wifi_IOT"
state_topic: "wifi_button_1"
input_select:
wifi_button_1_mode:
name: WIFI Button mode
options:
- "Bedroom Light"
- "Computer Light"
- "Dinning Room Light"
- "Outside Lights"
- "Lights off"
- "Holiday mode"
- "Movie time"
icon: mdi:target
Automation.yaml
- alias: WIFI IOT Button hide_entity: true trigger: platform: state entity_id: sensor.wifi_iot to: "connected" action: service: homeassistant.toggle data_template: entity_id: > {{ {'Computer Light': 'switch.computer_lamp', 'Dinning Room Light': 'switch.dinning_room', 'Outside Lights': 'switch.outside_lights', 'Bedroom Light': 'switch.bedroom_lamp', 'Holiday mode': 'group.holiday_mode', 'Movie time': 'group.movie_time_card', 'Lights off': 'script.lights_off' } [states('input_select.wifi_button_1_mode')] }}
(thanks to ‘pnbruckner’ for help sorting template).
Now the powerbank can be used normally, with the benefit of associating various actions to the button to control things (via HASSIO frontend).
The ESP01 uses a small amount of power when you push the button, but as soon as you let go it completely turns off… using no power. This has the disadvantage of taking a few seconds to connect to the wifi when pressed.
The powerbank is rechargeable so this wifi switch should last forever (within reason) and can be made to control whatever you want easily.