crserran / home-alarm

Alexa & Google Home alarm integrations and notifications system for your home security.
https://crserran.github.io/home-alarm
MIT License
21 stars 6 forks source link

[QUESTION] How do you call a script? #10

Closed LordNex closed 3 years ago

LordNex commented 3 years ago

Question

I'm wanting to make my lights toggle on and off, or red and blue for colored, when the alarm triggers. I've looked through the documentation but couldn't find anything there.

I could try and setup a webhook maybe and have the alarm systems try and use that address as an mp3 path. But that would also break the audio.

Any idea of a way to do this?

Additional information

AppDaemon app configuration


home_alarm:
  module: home_alarm
  class: HomeAlarm
  sensors:
    # - binary_sensor.garage_motion
    - binary_sensor.kitchen_window
    - binary_sensor.back_door
    - binary_sensor.back_door_tamper_sensor
  safe_mode: input_boolean.safe_mode
  activation_delay: 15
  stop_delay: 300
  alerts:
    - id: media_player
      sound: https://mydomain.duckdns.org:8123/local/MainAlarm.mp3 #https://bigsoundbank.com/UPLOAD/mp3/0268.mp3
      volume: 1
      loop_delay: 4
      media_players:
        - media_player.living_room_speaker
        - media_player.master_bedroom_speaker
        - media_player.bathroom_speaker
        - media_player.xxxxx_s_room_speaker
    - id: notifier
      notifiers:
        - notify.mobile_app_wwwww
        - notify.mobile_app_yyyyy_
        - notify.mobile_app_zzzzz
        - notify.mobile_app_xxxxx
        - notify.notify
      title: "ALARM ALERT! {sensor} has triggered!"
      message: "Someone/something triggered your Home Alarm! Better check {sensor} and see whats up!!"

Logs

(optional) Add relevant AppDaemon / Home Assistant logs which could help answering the question.

Additional Context

Add any other context or screenshots about the question here.

LordNex commented 3 years ago

Ok I did find the new section on your site about the lights. But again I would like to have the lights flash on and off or cycle between colors. I could do this with a script. I just need a way to trigger the script from the alarm trigger. Sorry, hopefully I'm explaining this right.

crserran commented 3 years ago

Hi @LordNex,

Yes Home Alarm has Light support. The default behaviour is to toggle the list of lights you set on your apps.yaml each second in RED color and brightness set to the maximum that is 255. You can configure your lights with the following config:

...
alerts:
    - id: light
      lights:
        - light.your_light_1
        - light.your_light_2
      rgb_color: [255, 0, 0]
      brightness: 255
...

I have notice that I forgot to update the documentation for the two last attributes that are rgb_color and brightness. You can set your color just writing your RGB Color in that array following [R, G, B] that is [Red, Green, Blue] for 0 to 255 each one. Moreover, you can set your light brightness from 0 to 255. That 2 attributes are common for the all list of lights.

I hope this helped you, Best regards,

Cristian.

LordNex commented 3 years ago

Perfect. Thank you very much. One question. Can you set a second color for the colored lights to go to. If not this'll work, would like to have the colored ones flash red and blue and then the normal ones just toggle. But switching back and forth from white and off or while and red would do it.

Right now I am just using a light group that contains every light in the house. Do I need to break that out and separate the colored from the normal into 2 separate groups? Again, thanks for all the help. I have already helped a few people I know set this up. And everyone thinks it's nicely done.

I'm also currently working on true facial recognition and I'm close. I'm only doing it with cheap Wyze cams and RSTP. Working now to make it easy to train new faces by training with a service that points to a picture file. I've already got DOODS doing basic object recognition and notifications and alarm triggers setup based on that. I have a Wyze lock and keypad coming this week too. Going to see if i can make it check not only facial recognition but GPS and Bluetooth to determine if you are a valid user and then grant access based on that. Would also be cool if I couple figure out a way to pass keypad codes that get entered from the Wyze keypad to be passed to Home Alarm to validate a user. When I get a little closer to that I'll let you know where it leads.

Peace

LordNex commented 3 years ago

Hey would this work for a notification? It works in an automation. Figured I'd ask before I just threw it in and tested it. Thanks

' - id: notifier notifiers:

crserran commented 3 years ago

Hi @LordNex

Sorry for the delay answering. Regarding your first question, by the moment it is not supported to have a second color for a single light alert. If you want to have some lights flashing in RED color an others in BLUE what you can do is create multiple light alerts in the apps.yaml file like this:

alerts:
    - id: light
      lights:
        - light.your_group_1
      rgb_color: [255, 0, 0]
      brightness: 255
   - id: light
      lights:
        - light.your_group_2
      rgb_color: [0, 0, 255]
      brightness: 255

If you have a light that not supports coloring in your group I think that this light just will ignore the color attribute and it will flash normally. Anyway you can test it yourself from Developer tools calling the service light.turn_on and the payload should be similar than this:

entity_id: light.your_light_group
rgb_color: [255, 0, 0]
brightness: 255

Regarding your last question about notifier, I think that this won't work with Home Alarm but it could be a good improvement.

Your facial recognition systems sounds really nice! If one day you decide to share your system with the community let me know 👍

Thank you for recommending the system to others. Regards

LordNex commented 3 years ago

I can put this in another issue if needed.

Is there a way to be able to run 2 instances of this on the same HA box? Basically I have the alarm setup so that it can be on while where home. I don't have my internal motion or contact sensors ran through it at the moment. What I would like to do is have basically 3 settings. Off, Home Armed, and Away Armed. The latter of the 3 monitoring all of my sensors. I thought about trying to build a automation based on a template that if it sees motion so many times that it toggles a helper binary sensor that Home Alarm monitors to trigger it. But I figured there is probably a much better solution.

But so far things are going really good with it. I have 5 Google minis and a Lenovo Smart Display acting as speakers, all the lights set to toggle on/red/off, and have it tied via zigbee to my Wyze Locks. I have a Wyze keypad but the current integration sucks. Luckily it works pretty well through zigbee but forgets it state sometimes.

Oh I also got true facial recognition working. Although it's current iteration is a little slow for greeting and unlocking the door. But I'm picking up a Jetson Nano and plan to run some DeepStack AI neural recognition to speed it up. So far from the tests me and a few people have ran it is doing true person facial recognition in about 500ms. I can then pass that as an ID to the system if the confidence that it is that specific ID of let say 95% or greater. So my hope is to be able to flesh this out into a buildable off the shelf AI controlled facial recognition Home Automation and Security System. We'll see anyway LOL

crserran commented 3 years ago

Hi @LordNex

The approach you are proposing is good. For the moment Home Alarm does not support this 3 states because it doesn't differentiate between motion and non motion sensors, all are treated as binary_sensors and when one of them goes to "on", then trigger the alarm.

I would like to propose to you a workaround that could be useful for your situation. You can create a new binary sensor on your HA instance and control its state taking into account if you are at Home or not and the motion sensors and then include this new binary sensor to the Home Alarm configuration. So, you will be able to arm the alarm when you are at home and if the motion sensor detects you, the alarm won't be triggered.