tagreader icon indicating copy to clipboard operation
tagreader copied to clipboard

Automation and led color

Open dominiquefournier opened this issue 1 year ago • 3 comments

I would like to script the color of the led to allow the led in red, yellow or green, drove by Alarmo.

I need to use script/automation to do that..

Is there a method to drive the led color directly from automation ? Thanks a lot

dominiquefournier avatar Feb 01 '25 17:02 dominiquefournier

I just managed to do that I think, but I have a slightly different setup. I am using an additional LED only for showing the status of Alarmo. Let me give you a few pointers:

  • You need a text sensor that executes something when the alarm status changes
    text_sensor:
      - platform: homeassistant
        id: alarm_state
        entity_id: alarm_control_panel.alarmo
        on_value:
          then:
            - light.turn_on:
                id: alarm_led
            - switch.turn_on: alarm_led_enabled
            - script.execute: update_leds
    
  • this is the script that does the color changes (i used effects since that seemed simpler)
     script:
      - id: update_leds
        then:
          - lambda: |-
              auto state = id(alarm_state).state;
    
              // Reset to off state
              id(alarm_led).make_call().set_effect("None").set_rgb(0.0, 0.0, 0.0).perform();
    
              if (state == "disarmed") {
                id(alarm_led).make_call().set_effect("None").set_rgb(0.0, 1.0, 0.0).perform();  // solid green
              } else if (state == "arming") {
                id(alarm_led).make_call().set_effect("Yellow White Strobe").perform();
              } else if (state == "armed_away" || state == "armed_home") {
                id(alarm_led).make_call().set_rgb(1.0, 0.0, 0.0).set_effect("Pulse Slow").perform();
              } else if (state == "triggered") {
                id(alarm_led).make_call().set_effect("Red Strobe").perform();
              }
    
  • you also need to execute the script on boot
    esphome:
      on_boot:
        priority: -10
        then:
         ..
        - delay: 2s
        - light.turn_on:
            id: alarm_led
        - script.execute: update_leds
    

let me know if you need any help @dominiquefournier

vincentization avatar Jun 26 '25 19:06 vincentization

@vincentization Thanks for your proposal. I solve the problem with 4 scripts (one by color), containing (Adapt the RVB to the requested color). Here is "TagReader Flash Led Red" : data: rgb_color: - 127 - 0 - 0 brightness_pct: 70 flash: long target: entity_id: light.tagreader_led action: light.turn_on

Then call on of them in alarmo action. When the alarm is disabled, call "TagReader Flash Led Green", when the alarm is enabled and waiting to people exit , call "TagReader Flash Led Orange", when the alarm is in error (because a window is opened), call "TagReader Flash Led Red"

dominiquefournier avatar Jun 30 '25 18:06 dominiquefournier

I am not sure if I understood correctly! Are these actions in home assistant that are also triggered in homeassistant?

vincentization avatar Jun 30 '25 22:06 vincentization