Home Assistant : Q&A, Tips & Tricks, Your Configs

Question. Has anyone built an automation that uses solar noon as a trigger to start/stop devices.

My pool pump is now connected to a SONOFF POW R2 (Tasmota) ... and I want it to run as as follows:-

If the solar noon at my place today is at 12:20, then I want the pool pump to start running 2 hours before that and to stop 2 hours after that. This way, I am hoping, I am maximising the amount of sun hitting my pool solar panels to warm the pool.

While hass.io has the Sun module which works out solar noon using "next_noon" .. how does one it in an automation?

Right now it's on a dumb timer - start at 10 and finish a 2pm ... :)

Thanks :D

Edit : Sun Module in Hass.io does have solar noon component - so updated post...

Nice idea actually.

Would you mind giving details on how you connected the pump to the Sonoff. I'd like to do the same with my Pool (As well as the pool light)
 
Nice idea actually.

Would you mind giving details on how you connected the pump to the Sonoff. I'd like to do the same with my Pool (As well as the pool light)

I guess the easiest way would be to cut the wire going to the pump and add the Sonoff into a waterproof housing.
Be sure the keep the ground connected.
 
Nice idea actually.

Would you mind giving details on how you connected the pump to the Sonoff. I'd like to do the same with my Pool (As well as the pool light)
I guess the easiest way would be to cut the wire going to the pump and add the Sonoff into a waterproof housing.
Be sure the keep the ground connected.


Yup that's what I did. Opened the Pool DB (inside pump enclosue, removed the electronic timer (in my case, Live Feed -> Breaker Switch -> Timer -> Pool Pump) so that it was (Live Feed -> Breaker Switch -> Sonoff POW R2 -> Pool Pump) . I chose to keep the breaker switch as it is it easier to turn pump off when I am doing backwashes, etc this way. So while I trigger the pump to be turn on via Hass.io, I then use the manual switch for cutting full power as I move that pool thing from filter, to backwash to rinse, etc.

Works well. 4 hours of my pool pump running is using on average 4.5 KwH of energy a day which is correct as my pump is 1.1Kw.
 
Yup that's what I did. Opened the Pool DB (inside pump enclosue, removed the electronic timer (in my case, Live Feed -> Breaker Switch -> Timer -> Pool Pump) so that it was (Live Feed -> Breaker Switch -> Sonoff POW R2 -> Pool Pump) . I chose to keep the breaker switch as it is it easier to turn pump off when I am doing backwashes, etc this way. So while I trigger the pump to be turn on via Hass.io, I then use the manual switch for cutting full power as I move that pool thing from filter, to backwash to rinse, etc.

Works well. 4 hours of my pool pump running is using on average 4.5 KwH of energy a day which is correct as my pump is 1.1Kw.

Nice. Did you also correct mounting for the Sonoff to fit on the switch board?
 
Nice. Did you also correct mounting for the Sonoff to fit on the switch board?

I had a DIN rail but it did not fit, so when I removed the electric timer, the space that it left was where the POW R2 is not sitting (behind the fascia board). I was worried about Wi-Fi signal as the whole enclosure is Waterproof and then the whole pool pump enclosure is abestos. But no worries. My Ubiquiti APs ensure that WiFi coverage is good! I plan on installing a Sonoff DUAL to control the Pool Light and some strip lights next to the pool. This will get it's own little waterproof box inside the pump enclosure - the plan is as follows:

(Enclosure 1:) Pool Pump DB -> Lights Breaker Switch -> (Enclosure 2:) > Sonoff Dual
Output 1: 220v Pool Light PSU -> 12V Pool Light
Output 2: 220v Strip Light PSU -> 12V Strip lights

By using Tasmota -> I can then set the Strip lights to come on 1 hour after sunset (which changes daily) and turn off at 10pm .. hoping it ends up looking as cool as I have pictured it in my mind :)
 
Glad to see there's a HA forum here

Some pics of my setup:
- https://prnt.sc/qktg3g
- https://prnt.sc/qktgl9
- https://prnt.sc/qktgrb
- https://prnt.sc/qkth6o

Tried the dark theme of lovelace but not a fan.
Anyone else want to show their integrations? My pool pump + heat pump are still on ewelink + sonoff pow, alarm is paradox via the ip150 module, cameras are hikvision (rtsp) and arlo (community addon), inverter I just setup a rest endpoint to get the values from my inverters web interface - I know some of the values I need to *-1, havent gotten to it yet.
 
Question. Has anyone built an automation that uses solar noon as a trigger to start/stop devices.

My pool pump is now connected to a SONOFF POW R2 (Tasmota) ... and I want it to run as as follows:-

If the solar noon at my place today is at 12:20, then I want the pool pump to start running 2 hours before that and to stop 2 hours after that. This way, I am hoping, I am maximising the amount of sun hitting my pool solar panels to warm the pool.

While hass.io has the Sun module which works out solar noon using "next_noon" .. how does one it in an automation?

Right now it's on a dumb timer - start at 10 and finish a 2pm ... :)

Thanks :D

Edit : Sun Module in Hass.io does have solar noon component - so updated post...
Nice idea for solar PV if you have hooked up to the pool pump as well - I am going to steal it :)
 
@InternetLuddite how did you do your trigger on the next_noon, what I've come up with is, for example, 2 hours before solar noon:

YAML:
- id: '1574362335029'
  alias: Pool On   
  description: '2 hours before solar noon'
  trigger:
  - value_template: "{{ as_timestamp(state_attr('sun.sun', 'next_noon')) - as_timestamp(now()) < 7200 and as_timestamp(state_attr('sun.sun', 'next_noon')) - as_timestamp(now()) > 0 }}"
    platform: template
  condition: []
  action:
  - alias: ''
    data: {}
    entity_id: switch.sonoff_10013a422c
    service: switch.turn_on
 
Last edited:
Have a look at the tod binary sensor. Makes things easier to read.
 
Glad to see there's a HA forum here

Some pics of my setup:
- https://prnt.sc/qktg3g
- https://prnt.sc/qktgl9
- https://prnt.sc/qktgrb
- https://prnt.sc/qkth6o

Tried the dark theme of lovelace but not a fan.
Anyone else want to show their integrations? My pool pump + heat pump are still on ewelink + sonoff pow, alarm is paradox via the ip150 module, cameras are hikvision (rtsp) and arlo (community addon), inverter I just setup a rest endpoint to get the values from my inverters web interface - I know some of the values I need to *-1, havent gotten to it yet.
@InternetLuddite how did you do your trigger on the next_noon, what I've come up with is, for example, 2 hours before solar noon:

YAML:
- id: '1574362335029'
  alias: Pool On  
  description: '2 hours before solar noon'
  trigger:
  - value_template: "{{ as_timestamp(state_attr('sun.sun', 'next_noon')) - as_timestamp(now()) < 7200 and as_timestamp(state_attr('sun.sun', 'next_noon')) - as_timestamp(now()) > 0 }}"
    platform: template
  condition: []
  action:
  - alias: ''
    data: {}
    entity_id: switch.sonoff_10013a422c
    service: switch.turn_on

Cool! I haven't had time to play with my setup recently to work it out - so I may just steal yours and save me the time :)

Cool setup by the way. Care to share the config you have for your gates/garage door? Mine is defined just as switch (turns on/off in 1 second - getting the value from the sonff with pulsetime I think.) But it has no clue as to whether it is opening or closing. With yours, does it go in the specific direction you tap on e.g. open/close. If yes, what magic to enable that. I still need to put a magnetic switch on gate/garage so that I can see in HASS if it actually is open or not.

I have an IP 150 too. What integration can I use to enable this? My IP is running swan/insite gold and I really want to toss that app since it is shite. I also do have an old IP150 that is running v1 firmware that I could possibly use.

With the eskom ****, thinking about getting solar/inverter too and my first requirement is that it has to be compatible with Hass so that when running on solar or batteries, certain things never run like geysers, stove, dishwasher, washing maching, Pool pump (unless it's getting fed by solar power and there is capacity). All these are already connected to a SONOFF (not the stove) so i got their power utilisation stats so know how to sort of size to manage and then hopefully if the input is that hass.io detects running on battery, then don't allow them to be turned on. The next project I hope to start in two months when I get some funds.
 
Cool! I haven't had time to play with my setup recently to work it out - so I may just steal yours and save me the time :)
Cool - go ahead. The issue with the next_noon is that as soon as it hits that time it changes to tomorrows next_noon, so for the "off" I just added a trigger to turn off the pool pump 4 hours since its state changed to "on"

Cool setup by the way. Care to share the config you have for your gates/garage door? Mine is defined just as switch (turns on/off in 1 second - getting the value from the sonff with pulsetime I think.) But it has no clue as to whether it is opening or closing. With yours, does it go in the specific direction you tap on e.g. open/close. If yes, what magic to enable that. I still need to put a magnetic switch on gate/garage so that I can see in HASS if it actually is open or not.
For the garage door I am using a D1 mini + relay shield + reed switch flashed with tasmota (setup following this guide: https://www.inspectmygadgets.com/wemos-d1-mini-garage-door-opener/) -- the reed switch is what signals if its open or closed and HASS greys out the relevant up/down arrow (the stop button is just a toggle). I have the same linked to my front gate but I haven't hooked up the reed switch due to there being no good place to put it, that's why the up+down+stop are all enabled (the buttons all just do a power on for whatever configured time you have set and then off again - I need to make mine 2 sec otherwise it doesnt always trigger).

I have an IP 150 too. What integration can I use to enable this? My IP is running swan/insite gold and I really want to toss that app since it is shite. I also do have an old IP150 that is running v1 firmware that I could possibly use.
I have an IP150 using the older firmware so it has the web interface - there is a community addon for it: https://github.com/maisken/Paradox_IP150 - it's just a little painful to setup because you need to manually add each zone as a binary_sensor - took me a little while to figure out the arm vs. disarm etc so if you get to this just give me a shout if you get stuck. I have it sending me a Telegram message every time it's armed/disarmed too.

With the eskom ****, thinking about getting solar/inverter too and my first requirement is that it has to be compatible with Hass so that when running on solar or batteries, certain things never run like geysers, stove, dishwasher, washing maching, Pool pump (unless it's getting fed by solar power and there is capacity). All these are already connected to a SONOFF (not the stove) so i got their power utilisation stats so know how to sort of size to manage and then hopefully if the input is that hass.io detects running on battery, then don't allow them to be turned on. The next project I hope to start in two months when I get some funds.
Solar setups are not cheap (100k+), when I first got it installed about 2 years ago the firmware didn't have a web interface that gave any values but an update recently introduced a status page which I saw was getting data from a json call, so I just took that URL and worked out which values were for what and set it up as a rest service in hass. I have an Ingeteam 1 Play 6kw inverter.
 
Solar setups are not cheap (100k+), when I first got it installed about 2 years ago the firmware didn't have a web interface that gave any values but an update recently introduced a status page which I saw was getting data from a json call, so I just took that URL and worked out which values were for what and set it up as a rest service in hass. I have an Ingeteam 1 Play 6kw inverter.

I'm also looking at going solar. Specifically looking at the Victron stuff - lots of open standards and API'S available.
 
I'm also looking at going solar. Specifically looking at the Victron stuff - lots of open standards and API'S available.
Personally I opted to rather go with what the installer recommended and not a fly by night installer either, so my research was more aimed at companies and of course their prices. Didnt go with the cheapest (a lot of axpert guys out there it seems) but not the most expensive either.

If you can find a good company to support it or if you are comfortable setting it up / debugging issues then go for it.

That said, I did make sure the inverter at least had an app to monitor it, luckily it ended up having a local web server I could scrape in the end.
 
@InternetLuddite FYI I noticed today HA seemed to lose its connection to my R2 for the pool pump so it's state logged as off and then on again quite a few times today (wifi repeater doesnt run during load shedding so the signal is weak) so my condition for the state change being on for 4 hours wasn't firing because it kept restarting.

What i did was add a new history sensor

YAML:
sensor:
  - platform: history_stats
    name: Pool on Today
    entity_id: switch.sonoff_10003a402c
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'

Then I setup a template automation to say if the pool pump is on and it's been on for over 4 hours today, switch it off, condition used:

YAML:
- id: '1574362335028'
  alias: Pool Off
  description: 4 hours run
  trigger:
  - platform: template
    value_template: '{{ states(''switch.sonoff_10003a402c'') == ''on'' and states(''sensor.pool_on_today'')
      | float > 4 }}'
  condition: []
  action:
  - alias: ''
    data: {}
    entity_id: switch.sonoff_10003a402c
    service: switch.turn_off

would prob kick off the pool if you manually switch it on for the day after its run for 4 hrs so not perfect..
 
@InternetLuddite FYI I noticed today HA seemed to lose its connection to my R2 for the pool pump so it's state logged as off and then on again quite a few times today (wifi repeater doesnt run during load shedding so the signal is weak) so my condition for the state change being on for 4 hours wasn't firing because it kept restarting.

What i did was add a new history sensor

YAML:
sensor:
  - platform: history_stats
    name: Pool on Today
    entity_id: switch.sonoff_10003a402c
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'

Then I setup a template automation to say if the pool pump is on and it's been on for over 4 hours today, switch it off, condition used:

YAML:
- id: '1574362335028'
  alias: Pool Off
  description: 4 hours run
  trigger:
  - platform: template
    value_template: '{{ states(''switch.sonoff_10003a402c'') == ''on'' and states(''sensor.pool_on_today'')
      | float > 4 }}'
  condition: []
  action:
  - alias: ''
    data: {}
    entity_id: switch.sonoff_10003a402c
    service: switch.turn_off

would prob kick off the pool if you manually switch it on for the day after its run for 4 hrs so not perfect..
Use an input boolean to manually turn it on,that way it knows it's an override. You then create a trigger to switch off the input boolean after x amount of hours.
 
Flashed ESPeasy to my ESP32 D1 boards I bought in error when I first started looking into all this home auto stuff (Tasmota doesn't work on ESP32). Put in a temperature and humidity sensor on the one board and just set up a 4 channel relay on the other board which I plan on using to control my irrigation solenoids. Linked to HA with mqtt

Only bummer is the lack of nice enclosures for this stuff20200114_202838.jpeg20200114_201248.jpeg
 
Aw
Flashed ESPeasy to my ESP32 D1 boards I bought in error when I first started looking into all this home auto stuff (Tasmota doesn't work on ESP32). Put in a temperature and humidity sensor on the one board and just set up a 4 channel relay on the other board which I plan on using to control my irrigation solenoids. Linked to HA with mqtt

Awesome stuff! where did you buy them?

I bought a Wemos D1 Uno from a local electronics shop over the weekend at a price of more than R300 :(

Plan is to use the Analog in and Tasmota / ESPEasy / ESPhome to do a simple battery monitor to monitor the two 7Ah batteries I use to power the Pi + Router during loadshedding.
 
Aw


Awesome stuff! where did you buy them?

I bought a Wemos D1 Uno from a local electronics shop over the weekend at a price of more than R300 :(

Plan is to use the Analog in and Tasmota / ESPEasy / ESPhome to do a simple battery monitor to monitor the two 7Ah batteries I use to power the Pi + Router during loadshedding.
Banggood has a 3 pack for 13 dollars just search for wemos d1 mini, their shipping is around 2 weeks.

Interesting project would like to see how you did it when you're done.

Espeasy isn't as pretty as Tasmota but it seems like it can do a lot more things at once than Tasmota. Espeasy doesn't have any specific home assistant integrations though so you have to manually add the sensors etc
 
I had a DIN rail but it did not fit, so when I removed the electric timer, the space that it left was where the POW R2 is not sitting (behind the fascia board). I was worried about Wi-Fi signal as the whole enclosure is Waterproof and then the whole pool pump enclosure is abestos. But no worries. My Ubiquiti APs ensure that WiFi coverage is good! I plan on installing a Sonoff DUAL to control the Pool Light and some strip lights next to the pool. This will get it's own little waterproof box inside the pump enclosure - the plan is as follows:

(Enclosure 1:) Pool Pump DB -> Lights Breaker Switch -> (Enclosure 2:) > Sonoff Dual
Output 1: 220v Pool Light PSU -> 12V Pool Light
Output 2: 220v Strip Light PSU -> 12V Strip lights

By using Tasmota -> I can then set the Strip lights to come on 1 hour after sunset (which changes daily) and turn off at 10pm .. hoping it ends up looking as cool as I have pictured it in my mind :)

Nice!

I managed to get my Soon POW and Basic hooked up to the pull db board with the help of a friend. Had the same concerns as you with WiFi but I have an outside UniFi Pro AP that made sure there was decent enough connection.

I don't have the DINs as yet for mounting; the Sonoff's are inside the Pool DB board, which is covered by a standard pool pump enclosure.

Can now turn the pool lights / Pump on with HA and/or Alex "Alex turn the pool lights off" works well.

I used ESPHome instead of Tasmota as it was easier to get on to the Sonoff for me using my Mac. I also use Node Red to do the automations (Sunrise / Sunset) etc
 
Just replaced my irrigation system with an ESP32 + 4 channel relay running espeasy, wife down another Tupperware til I find a decent way to mount these things
20200121_203527.jpeg
 
Top
Sign up to the MyBroadband newsletter