Update deCONZ integration to support `flash` with `color`

The other ones are in yaml so let keep it all the same

PR added

3 Likes

That is Awesome!

Hey all,

I was looking for flashing a light in a different color than white and came here following @D34DC3N73R’s original post. Great to hear there is a solution.

However, I am quite a noob to HA so if someone would be so kind to give me a step-by-step guide that would be amazing.

Thanks a lot in advance.

He has added a PR https://github.com/home-assistant/home-assistant.io/pull/15705

look at that and try to follow it and give @D34DC3N73R feedback on if it is clear enough.

To be clear, this is specific to users with Philips Hue bulbs connected via deCONZ. If that isn’t your situation, you’re probably better off using light.turn_on with flash and color.

If you are using hue with deCONZ, here are two examples.

script:
  hue_lamp_flash:
    alias: Hue Lamp Flash
    mode: single
    sequence:
    - service: deconz.configure
      data:
        field: /state
        data:
          'on': true
          hue: 65535
          sat: 255
          bri: 255
          alert: breathe
        entity: light.hue_lamp
    - delay: '15'
    - service: deconz.configure
      data:
        field: /state
        data:
          'on': false
        entity: light.hue_lamp

and an automation

automation:
  - alias: Flash Hue Bulb with Doorbell Motion
    mode: single
    trigger:
    - platform: state
      entity_id: binary_sensor.doorbell_motion
      to: 'on'
    action:
    - service: deconz.configure
      data:
        entity: light.hue_lamp
        field: /state
        data:
          'on': true
          hue: 65535
          sat: 255
          bri: 255
          alert: breathe
    - delay: 00:00:15
    - service: deconz.configure
      data:
        entity: light.hue_lamp
        field: /state
        data:
          'on': false
2 Likes

Yes, I am aware that this scenario is for the specific setup of Hue bulb with deConz Bridge, but I agree that it’s good to mention this clearly. This in fact is exactly my setup. Thanks a lot, will try it out later/tomorrow! Highly appreciated the full snippet.

Thanks again for those. Generally it work perfectly fine, I am trying to make some adjustments:

  • I would like to use a different color (want to use it based on a trigger, e.g. if my Football-Team scores). Does anyone have a list or page where I can see which value to use for which color?
  • Is there a way to store the previous state and color and fall back to it after the flash? I already realized changing the boolean of ‘on’ will keep the light on after the flash, but it will be in the flashing color. Of course I could set my “default color” statically, but I would like to store it before the flash and then use this value

Thanks in advance.

For the color picker you can use the HSV/HSB (Hue, Saturation, Brightness) values from http://colorizer.org/ but you will then need to convert the Hue, Saturation & Brightness values. This is because the Hue angle is represented as a value from 0-360 on most color picker sites but Philips Hue requires a value between 0 - 65535. Saturation & Brightness also need to be converted from a value of 0-100 to a value between 0-255.

Unfortunately I have not found a site that automatically converts the color into the correct HSB Values for Philips Hue Lights. If anyone else has please let me know but its easy enough using the formula below.

After getting the Hue, Saturation and Brightness from colorize.org use this formula to convert them to the philips hue values.

converted_hue=hue*65535/360
converted_saturation= (saturation/100)*255
converted_brightness=(brightness/100)*255

i.e.
From colorizer.org Green would give HSB Value of 120, 100, 50.2, so using the formula above the values would convert to 21845, 255,128.01:-

converted Hue==> 21845=120*65535/360
converted Saturation==> 255=(100/100)*255
converted Brightness==> 128.01=(50.2/100)*255

To store the previous state and colour i used this script


With the following node red flow.
image

[{"id":"a1bc983f.957278","type":"api-call-service","z":"126a5de8.16ec1a","name":"Light Store","server":"60e1db70.15c0ec","version":1,"debugenabled":false,"service_domain":"python_script","service":"light_store","entityId":"light.hallway_light1, light.hallway_light2, light.hallway_light3, , light.study_light","data":"{\"store_name\":\"flash_store\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":310,"y":1860,"wires":[["3200f241.bc8fb6"]]},{"id":"3200f241.bc8fb6","type":"api-call-service","z":"126a5de8.16ec1a","name":"Colour Lights","server":"60e1db70.15c0ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.alarm_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":472,"y":1860,"wires":[["6f7cae7c.b02bf"]]},{"id":"6f7cae7c.b02bf","type":"api-call-service","z":"126a5de8.16ec1a","name":"Light Store","server":"60e1db70.15c0ec","version":1,"debugenabled":false,"service_domain":"python_script","service":"light_store","entityId":"light.hallway_light1, light.hallway_light2, light.hallway_light3, , light.study_light","data":"{\"store_name\":\"flash_store1\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":630,"y":1860,"wires":[[]]},{"id":"b94e1e69.6ac498","type":"api-call-service","z":"126a5de8.16ec1a","name":"Light ReStore","server":"60e1db70.15c0ec","version":0,"service_domain":"python_script","service":"light_store","data":"{\"store_name\":\"flash_store1\",\"operation\":\"restore\"}","mergecontext":"","output_location":"","output_location_type":"none","x":320,"y":1920,"wires":[["5acfa45a.a42344"]]},{"id":"dcbfbc36.e8bd8","type":"api-call-service","z":"126a5de8.16ec1a","name":"Light ReStore","server":"60e1db70.15c0ec","version":0,"service_domain":"python_script","service":"light_store","data":"{\"store_name\":\"flash_store\",\"operation\":\"restore\"}","mergecontext":"","output_location":"","output_location_type":"none","x":640,"y":1920,"wires":[[]]},{"id":"5acfa45a.a42344","type":"delay","z":"126a5de8.16ec1a","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":480,"y":1920,"wires":[["dcbfbc36.e8bd8"]]},{"id":"c00fcfe.09584b","type":"inject","z":"126a5de8.16ec1a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":1860,"wires":[["a1bc983f.957278"]]},{"id":"6065d9d.58dba28","type":"inject","z":"126a5de8.16ec1a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":1920,"wires":[["b94e1e69.6ac498"]]},{"id":"60e1db70.15c0ec","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

The first Light Store node stores the state of the lights that are on or off. Then I switch all the lights on so the 2nd Light Store node saves the colour and brightness values. Then I restore them in reverse order.

Much appreciated. I was already successful setting colors and will look into the python script next.

Just to give some Idea what I am trying to achieve, I want lights to flash if my Football Team scores a goal respectively when the Packers score. Will probably looking to use a webhook for the trigger.

Your house is going to look like a rave with the way Rodgers is playing. GPG

Thanks, let’s hope so. Do you have any idea what I could use as a trigger?

I found this NFL json. https://static.nfl.com/liveupdate/scorestrip/ss.json

Guessing you’d have to use some type of rest sensor with a value template, but I’d have to read into how to do that.

I wasn’t able to test this out in-game, but I think it should work. It tests every 2 minutes, so that may need to be fine-tuned.

sensor:

  - platform: rest
    resource: https://static.nfl.com/liveupdate/scorestrip/ss.json
    name: Packers Score
    value_template: >
      {% for game in value_json.gms %}
        {% if game.h == 'GB' or game.v == 'GB' %}
          {% if game.q != 'F' and game.q != 'P' and game.q != 'FO' and game.q != 'S' %}
            {% if game.h == 'GB' %}
              {{ game.hs }}
            {% else %}
              {{ game.vs }}
            {% endif %}
          {% else %}
            0
          {% endif %}
        {% endif %}
      {% endfor %}
    scan_interval: 120

automation:

- alias: Go Pack Go
  mode: single
  trigger:
  - platform: state
    entity_id: sensor.packers_score
  condition:
  - condition: not
    conditions:
    - condition: state
      entity_id: sensor.packers_score
      state: '0'
  action:
  ...

Finally found some time to get back to this. I could add the python-script so this part is settled. However, I have no idea how to work with Node Red. I already installed it and obviously understand the drag and drop. What is not clear to me is, what to put into the individual nodes. Could you help me out with that or guide me where to start reading?

Hi, have you tried importing the code in the flow I posted. If not copy the flow code from my previous post then in node red
click 3 lines top right
Import flow
Paste it from clipboard

Then change the entity Id’s in the nodes to correspond to your lights
1st node - store on off states of lights listed as entity id
2nd node - turn on lights listed as entity id
3rd node - store attributes of lights (I.e colour, brightness)

Apologies for the brief reply but don’t have access to my home assistant at the moment. If you’re still unsure of how it is set up let me know and I should have some time tomorrow for a more detailed reply.

Thanks again. Importing works and I understood the changes for the 1st and 2nd node. I am uncertain regarding node 3 (how to store the the attributes). Can you help me here?

And regarding my automation, how would I call it exactly? I would understand it the following way:

  • Define Triggers and conditions
  • call python_script.light_store as service -> does this need any payload?
  • call service deconz.configure with respective payload to flash the bulbs
  • call python_script.reload -> does this need any payload?

Does that look correct?

Hi,

What kind of color system are you using here? I can’t figure out a different color. When I look for HSB color system it gives options for 0-255.

It’s covered in the post here: