Two timers, one switch and a thermometer - automation issues

Hi everyone.

I’m new to home automation and very excited about it and still trying to get my head around it all.
I’ve watched countless numbers of videos to help teach myself but still have a few things I dont understand and would very much appreciate any help setting up my first Automation with the Sonoff TH16 switch.

So far I have:

  • Installed Hassio on RPi3B+
  • Successfully flashed the Sonoff TH
  • Set up MQTT Mosquito on Hassio
  • Successfully used “discovery” to find the Sonoff TH in Hassio (not sure if discover is the best option for entities?)
  • The Temperature is visible in Hassio
  • The switch works and can be toggled in Hassio

I am trying to create an automation that will:

  • Turn on the switch at 08:00
  • Turn off the switch at 10:00
  • Turn on the switch at 16:00
  • Turn off the switch at 18:00

This automation needs to run daily

I also need:

  • A toggle that I can use to manually turn on the switch and it will stay on until I manually turn the toggle off

I have googled everything, but am having a hard time with the sensor.time (not even sure if I should be using this?)
I can set a specific time and activate the switch, but can not figure out how to do the rest.

My Sonoff TH details are as follows:
switch.spa
sensor.sonoff_ds18b20_temperature

Thank you so much in advance!!

Kind regards

Paul

Write four automations of this format to turn on and off at the required times. The condition check of the state of the input_boolean is your manual override.

- id: on_at_0800
  alias: 'On at 08:00'
  trigger:
    platform: time
    at: '08:00:00'
  condition:
    condition: state  ### only if the override switch is off (you really only need this condition block in the 'off' automations.)
    entity_id: input_boolean.override_switch
    state: 'off'
  action:
    service: switch.turn_on
    entity_id: switch.your_sonoff_switch_id_here

And one automation to turn the switch on with the override input boolean:

- id: switch_override   
  alias: 'Switch Override'
  trigger:
    platform: state
    entity_id: input_boolean.override_switch 
    to: 'on'
  action:
    service: switch.turn_on
    entity_id: switch.your_sonoff_switch_id_here

Your ‘override’ input_boolean should look something like this:

override_switch:
 name: Override Switch
 icon: mdi:power   ### choose whatever you want from the 'material design icons' web page.
1 Like

Thank you so much @tom_l for your help. I really appreciate it!
This is fantastic support!!
I’m going to work on this shortly.
I’ll let you know how I go.

Many thanks again :+1::+1::+1::+1::+1::+1:

I think you can simplify it to only two on / off automations, like so:

- id: on_at_0800_and_1600
  alias: 'On at 08:00 and 16:00'
  trigger:
    - platform: time
      at: '08:00:00'
    - platform: time
      at: '16:00:00'
etc...
- id: off_at_1000_and_1800
  alias: 'Off at 10:00 and 18:00'
  trigger:
    - platform: time
      at: '10:00:00'
    - platform: time
      at: '18:00:00'
etc...
1 Like

thats excellent!
I’ll give it a go :slight_smile:
Thanks again pal!!!

just wanted to say thanks again @tom_l for your support.
it worked like a treat.
I have also disabled “discovery” of MQTT entities and have learnt how to add them manually. :slight_smile: