Hello everyone. This continues with the software of an esp32 that manages a board of 8 relays that control an aquarium. Now I would like to see how to make the esp be the one that handles the turning on and off of the lights without depending on the wifi. They helped me before with the temperature issue. Now I have a couple of questions. If I manage this on the esp side, who controls what the real time is? On the home assistant side, I have two variables of the type datetime in which I configure from the UI which is the start time and which is the shutdown time. If I want this to continue to be configured from HA, would I have to separate the hour from the minutes to be able to configure it from esphome?
Is this code ok? How do I use the two datetime variables that I use in HA?
globals:
- id: minutes_on
type: int
restore_value: yes
initial_value: '0'
- id: hours_on
type: int
restore_value: yes
initial_value: '15'
- id: minutes_off
type: int
restore_value: yes
initial_value: '0'
- id: hours_off
type: int
restore_value: yes
initial_value: '23'
number:
- platform: template
name: "set minutes on"
id: set_minutes_on
optimistic: true
min_value: 0
max_value: 59
step: 1
on_value:
- globals.set:
id: minutes_on
value: !lambda 'return id(set_minutes_on).state;'
- platform: template
name: "set hour on"
id: set_hours_on
optimistic: true
min_value: 0
max_value: 23
step: 1
on_value:
- globals.set:
id: hours_on
value: !lambda 'return id(set_hours_on).state;'
- platform: template
name: "set minutes off"
id: set_minutes_off
optimistic: true
min_value: 0
max_value: 59
step: 1
on_value:
- globals.set:
id: minutes_off
value: !lambda 'return id(set_minutes_off).state;'
- platform: template
name: "set hour on"
id: set_hours_off
optimistic: true
min_value: 0
max_value: 23
step: 1
on_value:
- globals.set:
id: hours_off
value: !lambda 'return id(set_hours_off).state;'
time:
- platform: sntp
# ...
on_time:
# Cada dia a las 15hs
- seconds: 0
minutes: 0 #minutes_on
hours: 15 #hours_on
then:
- switch.turn_on: relay_8
# Cada dia a las 23hs
- seconds: 0
minutes: 0 #minutes_off
hours: 23 #hours_off
then:
- switch.turn_on: relay_8