Multiple sunset triggers not working

I have been struggling with automations not being triggered at the correct time. I have narrowed it down to having multiple triggers based on sunset - one being controlling the outdoor lightning and one turning on the mosquito lamp.
Didn’t notice it at first while troubleshooting the outdoor lightning, but the mosquito lamp turned on at sunset and off at sunrise while the outdoor lights always were late to activate (~35 min late).
I have now turned off the mosquito lamp automation and the outdoor lights now operate as expected.

You need to post your automation. Unless you just want to share with us what you are struggling with at the moment :wink:

Mosquito catcher:

alias: Flugfångare På
description: ''
trigger:
  - platform: sun
    event: sunset
condition: []
action:
  - type: turn_on
    device_id: 6ece2da35e3e1c4a001701e073dbcf25
    entity_id: switch.node10
    domain: switch
mode: single

and outdoor lightning:

alias: Utebelysning kväll (tänd)
description: ''
trigger:
  - platform: sun
    event: sunset
condition: []
action:
  - service: homeassistant.turn_on
    target:
      entity_id: group.utebelysning
  - type: turn_on
    device_id: 4c84d15f294384c5f58007d2320ea973
    entity_id: switch.utebel_siffror
    domain: switch
  - type: turn_on
    device_id: 6ece2da35e3e1c4a001701e073dbcf25
    entity_id: switch.node10
    domain: switch
mode: single

If they are both enabled, the outdoor lights are turning on late. Mosquito lamp always work as expected - I don’t know if the automations runs alphabetically, can try to rename outdoor lights…

Since both automations rely on Zwave, could this be the issue? They both push commands into the Z-Wave integration (I’m using the deprecated old one).

You could try the automation debugger:

Just remember to add an id to the automation itself.

If there is nothing wrong with the automations I would start looking into Z-wave, as you suggested. I have no idea how to debug that.

I had zwave issues with outdoor lights. They tend to be on the edge of the network so signal strength isn’t as good as closer devices inside. When I would try multiple switches at once I would get errors in the zwave logs from commands not going through and the zwave network flooding.

I would upgrade to the new zwave js Integration since the logging and performance are much better at some point. Once you have those zwave logs you can troubleshoot and try healing nodes/the network.

Another thing that worked for me was just offsetting each switch by 30 seconds. I did this in Node red with a delay timer but u probably can just make two automations with an offset. This way the first command goes through and gives the network time to settle before the next one.

Not really a solution to the “problem”, per se, but, since both automations use the exact same trigger and no conditions, it might help if you combined both actions into the same automation.

the actions should be sequential so if it is a zwave message collision issue then the sequencing might give just enough of a delay to prevent it from happening.

They tend to be on the edge of the network so signal strength isn’t as good as closer devices inside.

Even though the outdoor lights are many and far away, they are controlled by a Fibaro FGS223 located in the wiring cabinet, 2 ft from the HA server, and on a single electrical line.

I would upgrade to the new zwave js Integration since the logging and

Despite multiple attempts I never got the new integration to recognize my Aeon ZW090+ Gen5 USB stick. With the “old” integration it worked right away - Up against a Z-wave wall help I am DROWNING - #5 by msa This was back in March 2021 so maybe the integration has gotten better, but I don’t look forward redoing everything…

Another thing that worked for me was just offsetting each switch by 30 seconds.

Will try that and use scripts instead of groups. Too bad the groups can’t be configured with such delay…

Not really a solution to the “problem”, per se, but, since both automations use the exact same trigger and no conditions, it might help if you combined both actions into the same automation.

Yeah, thought of that as well. The down-side I can see is that it won’t be possible to disable the mosquito lamp during winter without editing the entire automation. I have changed the mosquito lamp to be time-triggered instead (21:00 to 06:00 instead of sunset to sunrise not to collide with the outdoor lamp trigger) and yesterday all automations worked and triggered at the exact time.

Keeping fingers crossed :crossed_fingers:t2:

I read your linked post and can see your pain. I’m actually using ZwaveJS2MQTT in a docker container, so although integrated in Home Assistant it does actually run separate versus the integrated ZwaveJS that runs in Home Assistant OS that you tried. They are similar but I’ve found the 2MQTT version has added logging features, a nice UI interface, and a nice network graph, that has helped me diagnose some problem Zwave devices. More info on the project here - https://zwave-js.github.io/zwavejs2mqtt/#/

The whole Zwave JS and Zwave JS2MQTT projects are being actively developed and improved so its possible it could work now with the updates they made, but I agree with you it would be a huge pain to switch over. Eventually you might have to though since the open zwave is deprecated, so I don’t know how much longer it will continue working.

On a side note from what I saw on your linked post, I do have two Kwikset locks working fine in Zwave JS2MQTT. Kwikset locks do “whisper” pairing though and people using many other hubs - including Smartthings and Hubitat, have had problems pairing them. For initial pairing, you need to take the lock off and literally have it next to the Zwave Hub/Stick (some have actually reported they needed to duck tape them together) to get the secure “whisper” pairing to work generally.

So range definitely doesn’t look like an issue. It still is really odd to have a 35 minute delay. My delay prior to offsetting was only a couple of minutes. Reading all your posts, it almost looks like you might have a corrupted Zstick. On a few of the Github issues reported on ZwaveJS2MQTT, a corrupted zstick was the cause of many issues similar to yours. Hard to say for sure though.

Offsetting the automations by 30 seconds or a minute may be the simplest solution for now, but it still sounds like there is a bigger underlying problem somewhere in your zwave network, controller stick, or system configuration. Another problem I’ve has is some devices report power status, like Inovelli switches, and if you have the parameters set to report the status too often, that floods the Zwave network with commands and slows it down. May also be worth looking at the advanced config settings for power management and reporting on your devices to make sure they are not reporting too often.

The deprecated OpenZwave honestly isn’t that good and just doesn’t have great logging and troubleshooting options, so unfortunately all these suggestions are just shots in the dark without more info.

I like Node Red for seasonal automations. Here’s a flow for my outdoor lights that only turn on in the summer. It uses the Home Assistant Time node that allows for sunset and to specify an offset

[{"id":"fd499bf.f481be8","type":"ha-time","z":"c372fc21.3059d","name":"Dusk","server":"ae531ce.a39906","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityId":"sun.sun","property":"attributes.next_setting","offset":"-20","offsetType":"num","offsetUnits":"minutes","randomOffset":false,"repeatDaily":true,"payload":"$entity().state","payloadType":"jsonata","debugenabled":true,"x":90,"y":1480,"wires":[["c81edb13.ec0aa8"]]},{"id":"c81edb13.ec0aa8","type":"api-render-template","z":"c372fc21.3059d","name":"Current Month","server":"ae531ce.a39906","version":0,"template":"{{ now().month }}","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"month","templateLocationType":"msg","x":260,"y":1480,"wires":[["db999420.141a3"]]},{"id":"db999420.141a3","type":"switch","z":"c372fc21.3059d","name":"Summer?","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"4","vt":"num","v2":"10","v2t":"num"}],"checkall":"false","repair":false,"outputs":1,"x":440,"y":1480,"wires":[["e198045f.881c58"]]},{"id":"e198045f.881c58","type":"api-call-service","z":"c372fc21.3059d","name":"Outdoor Plug","server":"ae531ce.a39906","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.outdoor_plug","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":630,"y":1480,"wires":[[]]},{"id":"ae531ce.a39906","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Unless you put as another condition in the actions before that the season is “not winter” before allowing that action to proceed. :stuck_out_tongue_winking_eye:

it’s better to handle the conditions in the automation instead of disabling the automation anyway.

1 Like

@finity that would probably be a lot easier. I used Node Red before Home Assistant so a lot of times miss the easier solution in the automation. Would you just create a “season” sensor like mentioned here Season - Home Assistant and then have that sensor be “not winter” in the automation condition?

Thank you for valuable information and feedback! Much appreciated!!
We are actively phasing out Zwave and moving to DIY-nodes based on Wemos and Sonoff running esphome. Ironically we moved from 433 MHz to Zwave to rely on the meshing functionality but that seems to have been a bad decision (we live in an old homestead house circa 1890 with thick lumber walls and challenging environment for WiFi and Zwave). With UniFi WiFi and 7 APs we have managed to get coverage in main building, stable and toolsheds.
Maybe we will keep Zwave for plugs in the outlets for lamps, coffeemaker etc. I will look into the issue with the Zstick and see if there are any firmware updates available.
The problems with the outdoor lights are at least solved for now and that’s good moving into winter with sunset earlier and earlier - living in Sweden, sunset is 2:30 PM when it’s darkest. Hard to imagine now in the summer with sunset 10:15 PM…

yeah, that should probably work but you need to put it in the “action:” section and not in the “condition:” section.

I don’t know what device is your mosquito lamp but here is an example:

condition: []
action:
  - type: turn_on
    device_id: 6ece2da35e3e1c4a001701e073dbcf25
    entity_id: switch.node10
    domain: switch
  - condition: not
    conditions:
      condition: state
      entity_id: sensor.season
      state: "winter"
  - type: turn_on
    device_id: 4c84d15f294384c5f58007d2320ea973
    entity_id: switch.utebel_siffror
    domain: switch
  - type: turn_on
    device_id: 6ece2da35e3e1c4a001701e073dbcf25
    entity_id: switch.node10
    domain: switch

Make sure you make the condition only block the last things you want to conditionally run because if the condition in the action isn’t met then the automation ends as soon as it gets to that point.

1 Like