ESP8266 Relay on_time activation

Hello. I have no raspberry pi, so at this time i learn hass.io on my virtual machine, so i need standalone esp8266 which enable light at 8am till 11am and 17pm till 21pm.
I write simple config and it not work :frowning:


switch:
- platform: gpio
id: relay1
name: “Relay 1”
pin: D1
inverted: True
restore_mode: ALWAYS_OFF
- platform: gpio
id: relay2
name: “Relay 2”
pin: D2
inverted: True
restore_mode: ALWAYS_OFF
- platform: gpio
id: relay3
name: “Relay 3”
pin: D5
inverted: True
restore_mode: ALWAYS_OFF
- platform: gpio
id: relay4
name: “Relay 4”
pin: D6
inverted: True
restore_mode: ALWAYS_OFF
time:
- platform: sntp
id: sntp_time
timezone: Asia/Krasnoyarsk
on_time:
- seconds: /5
then:
- switch.toggle: relay1

i can enable and disable relays via hass.io GUI, but it not toggle automatically every 5 seconds.
Where is my mistake? Thanks!

Rather than posting an image do this:

The config you have posted looks correct. Is the ESP actually connecting to the network (and thus able to connect to the ntp servers)?

ohhh, thanks!
there is no dns servers in static wifi ip address configurations section. So esp cannot connect to ntp servers.
I add dns servers and now it work!
Thank you again :slight_smile:
PS: i try format code like you show, but it not formatting correctly, so i append screenshot to view formatting :slight_smile:

Look very closely at the animated gif: paste, highlight, press <>.

Glad to hear you got it working.

1 Like