I’m trying to convert simple 3V battery operated air freshener to timer/wi-fi operation, via ‘ESPHome’. It is simple device with 3V DC motor in it, activating spray.
At 1st stage - to check if it works with ‘ESPHome’, at next step maybe integrate with ‘Home Assistant’…
This is the circuit I’m going to solder…
And the code for ‘ESP-07’ module…
As you see it will be operating at certain hours/minutes.
The question is: is it possible to have simpler code for such timer operations?
esphome:
name: air_refreshener_bath_small
platform: ESP8266
board: esp07
switch:
# manual activation/switch in HA
- platform: gpio
name: "Air Refreshener Bath Small"
pin: GPIO12
id: dc_motor
time:
# the morning cycle, working days, 05:25
- platform: sntp
id: 1_cycle_wd_morning
on_time:
- seconds: 0
minutes: 25
hours: 5
days_of_week: MON-FRI
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the morning cycle, working days, 06:00
- platform: sntp
id: 2_cycle_wd_morning
on_time:
- seconds: 0
minutes: 0
hours: 6
days_of_week: MON-FRI
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the afternoon cycle, working days, 15:30
- platform: sntp
id: 3_cycle_wd_afternoon
on_time:
- seconds: 0
minutes: 30
hours: 15
days_of_week: MON-FRI
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the evening cycle, working days, 18:30
- platform: sntp
id: 4_cycle_wd_evening
on_time:
- seconds: 0
minutes: 30
hours: 18
days_of_week: MON-FRI
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the evening cycle, working days, 20:00
- platform: sntp
id: 5_cycle_wd_evening
on_time:
- seconds: 0
minutes: 00
hours: 20
days_of_week: MON-FRI
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the evening cycle, working days, 21:00
- platform: sntp
id: 6_cycle_wd_evening
on_time:
- seconds: 0
minutes: 00
hours: 21
days_of_week: MON-FRI
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the morning cycle, holiday days, 07:25
- platform: sntp
id: 1_cycle_hd_morning
on_time:
- seconds: 0
minutes: 25
hours: 7
days_of_week: SAT-SUN
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the morning cycle, holiday days, 09:15
- platform: sntp
id: 2_cycle_hd_morning
on_time:
- seconds: 0
minutes: 15
hours: 9
days_of_week: SAT-SUN
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the afternoon cycle, holiday days, 12:30
- platform: sntp
id: 3_cycle_hd_afternoon
on_time:
- seconds: 0
minutes: 30
hours: 12
days_of_week: SAT-SUN
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the afternoon cycle, holiday days, 14:45
- platform: sntp
id: 4_cycle_hd_afternoon
on_time:
- seconds: 0
minutes: 45
hours: 14
days_of_week: SAT-SUN
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the evening cycle, holiday days, 16:45
- platform: sntp
id: 5_cycle_hd_evening
on_time:
- seconds: 0
minutes: 45
hours: 16
days_of_week: SAT-SUN
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the evening cycle, holiday days, 18:30
- platform: sntp
id: 6_cycle_hd_evening
on_time:
- seconds: 0
minutes: 30
hours: 18
days_of_week: SAT-SUN
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor
# the evening cycle, holiday days, 20:25
- platform: sntp
id: 7_cycle_hd_evening
on_time:
- seconds: 0
minutes: 25
hours: 20
days_of_week: SAT-SUN
then:
- switch.turn_on: dc_motor
- delay: 2s
- switch.turn_off: dc_motor