I am trying to use existing alarm PIR sensors to turn on/off lights following the integration of my alarm system to HA using a custom integration code found on github
I ve setup the automation code as follows:
- id: one
alias: office light
description: office light
trigger:
- platform: state
entity_id: sensor.integra_pir_grafio
to: '[VIOLATED]'
action:
- service: light.turn_on
target:
entity_id: light.office_light
data:
brightness: 255
However, it doesnt work. I can manually run the automation from the GUI but, it doest get triggered when the sensor is activated. I suspect the problem is with the change
to :[violated]
There is a sensor created for each of the alarms zones which shows as " [] " or as â[violated]â when active.
Go to Developer Tools, select the tab State and then search for sensor.integra_pir_grafio. Record the state exactly as it is (case sensitive). If possible to force the violated situation, do that and see the results on this tab.
- id: one
alias: office light
description: office light
trigger:
- platform: state
entity_id: sensor.integra_pir_grafio
to: "['VIOLATED']"
action:
- service: light.turn_on
target:
entity_id: light.office_light
data:
brightness: 255
It looks like it try to return a list, so you probably will have other possible results to this sensor including some case where âVIOLATEDâ is one of multiple simultaneous results.
If that is the case, you probably will have more precise results using a template trigger.
Something like this (not tested):
I will try that thanks!
And yes, there other options to the states besides VIOLATED like TAMPERED, ALARMED, BYPASSED but those dont happen during normal operation
PS: I ve only beem using HA for a couple of weeks now and I find it hard to find good documentation regarding YAML language. I find whats included in the HA docs insufficient. Are there any other online sources ?
I still believe this forum is the best place to learn⌠and donât be shy to ask questions here.
But Home Assistant is based on Python and uses Jinja a lot⌠Apart of the Home Assistant docs, there are plenty of docs for those platforms everywhere. Google will help a lot.
Well comparing my learning curve here with the one I had with arduino and C programming, this one is more steep! Forums are there to mainly to solve problems and they shouldnât substitute documentation.
Be the way your input has helped alot and it now works both for ON and OFF. How do I now add a time delay for the lights to stay on after the sensor de-acivates?
I just modified the motion sensor blueprint to also take values from my alarm sensors and it works!
YAML is a Markup Language that is used by a lot of systems. (âYAML Languageâ is redundant: âYet Another Markup Language Languageâ).
So documentation of YAML is very use-specific. Since most of us will never be using YAML in another system other than Home Assistant, then your best place to learn to use YAML is here on the Home Assistant forums.
Fortunately there are some users here who are well-versed in all things YAML. Without their help I could never have graduated from âYAML Illiterateâ to âYAML Challengedâ. ("YAML Challenged means that any answer I provide has a 50-50 chance of being wrong).
One thing I have learned is that you will never be traumatized by asking a YAML question here.
About the HA Docs:
You have to remember that the docs are written by the developer community who all speak in YAML. Once you understand the basic structure of YAML in Home Assistant the docs will make a little more sense. (Very little). Fortunately many of the developers are active on the forum.
I am always learning. For example just yesterday I learned what the error: âexpected dict for dictionary valueâ means. And I have been struggling with YAML for two years. (So, THAT is what a dict is!).
Over he past two years, the UI has been getting the average user more away from YAML files. Making my life easier. (My first configuration.yaml file was hundreds of lines long).