Een airwickverstuiver die om de zoveel minuten spuit is leuk, maar dat kan beter. Er zit een stukje electronica in, dus dat is te modificeren, en te autmatiseren!
Een ESP-01S ESP8266 Module inbouwen in het batterij compartiment, een power adapter toevoegen, één en ander aan ellkaar knopen en de IOT Airwick was een feit!
De ESPHome code:
esphome:
name: airwick
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "**********************************************"
ota:
password: "*************************************"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Airwick Fallback Hotspot"
password: "*******************"
captive_portal:
switch:
- platform: gpio
pin: GPIO0
name: "Airwick switch"
inverted: true
# The following can be omitted
- platform: restart
name: ${devicename} restart
sensor:
- platform: wifi_signal
name: ${devicename} wifi signal
update_interval: 600s
# human readable uptime sensor output to the text sensor above
- platform: uptime
name: ${devicename} Uptime in Days
id: uptime_sensor_days
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor_days).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
time:
- platform: homeassistant
id: homeassistant_time
# Text sensors with general information.
text_sensor:
# Expose ESPHome version as sensor.
- platform: version
name: $devicename Version
# Expose WiFi information as sensors.
- platform: wifi_info
ip_address:
name: $devicename IP
bssid:
name: $devicename BSSID
# human readable update text sensor from sensor:uptime
- platform: template
name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start