Triggering on state attributes of sun.sun

Working on moving my yaml automation to Node Red and I can’t figure out how to convert this automation:

  trigger:
  - platform: template
    value_template: '{{ state_attr(''sun.sun'', ''elevation'') < 6 }}'
  condition:
  - condition: template
    value_template: '{{ state_attr("sun.sun", "rising") == false }}'
  action:
  - data:
      entity_id: light.outside_garage_light
    service: light.turn_on
  - data:
      entity_id: light.pole_light
    service: light.turn_on
  - data:
      entity_id: light.mailbox_light
    service: light.turn_on
  - data:
      entity_id: light.corner_light
    service: light.turn_on

The trigger and condition is what is tripping me up. I have been looking at the trigger state and event state. I’m just not sure how to access the two attributes used. I’m new to Node Red and still learning, but need some help with this.

image

[{"id":"73e3c4f1.ea054c","type":"trigger-state","z":"ffbd7f06.4a014","name":"","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sun.sun","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"gc922kgju9f","targetType":"this_entity","targetValue":"","propertyType":"property","propertyValue":"new_state.attributes.rising","comparatorType":"is","comparatorValueDatatype":"bool","comparatorValue":"false"},{"id":"gcb3heh0b7m","targetType":"this_entity","targetValue":"","propertyType":"property","propertyValue":"new_state.attributes.elevation","comparatorType":"<","comparatorValueDatatype":"num","comparatorValue":"6"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":222,"y":768,"wires":[["33810232.94692e"],[]]},{"id":"33810232.94692e","type":"api-call-service","z":"ffbd7f06.4a014","name":"","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.outside_garage_light, light.pole_light, light.mailbox_light, light.corner_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":442,"y":768,"wires":[[]]}]
4 Likes

Thanks. Got to learn two things with that. First, how to import the node info (had been wondering about those), and some more info on the trigger node. I have been finding the documentation really lacking on some of this.