Govee Home Products / Dreamcolor LED strip

I have updated my Govee integration with some node-red magic and the help of @tetienne 's pull request.

Refer to that update here https://community.home-assistant.io/t/color-support-for-light-template/46651/7

I setup a fake template light that now has color temperature and a color wheel.

With node red I setup the flow as such so the light and all of its features are fully accessible like a real light.

If you need some help trying to implement like I did, feel free to ask otherwise use my idea, as its relativity easy to setup.

Glad to see you use my PR :smiley: I don’t use Node Red, can you explain why it’s usefule to redifined your ligh in node red?

Govee does not have a public api, however their LED strip is both cheap and high quality. The led strip is able to be controlled via Alexa so node red has a plugin called Alexa remote 2 which can access the smart home api. So by using node red when the brightness, color, or color temperature chages on the template light it sends that payload to the Alexa api to change the led stripe state. This in return makes a fully addressable light in home assistant!

That’s the first time I saw such configuration. That’s really clever :bulb:

1 Like

Can you share your settings on template light and on node-red?

It is very sloppy code but sure

Light Template: Package

input_boolean:
  govee_strip:

input_number:
  govee_strip:
    min: 0
    max: 255
  govee_temperature_input:
    min: 0
    max: 500
  govee_h_input:
    min: 0
    max: 360
  govee_s_input:
    min: 0
    max: 360

light:
  - platform: template
    lights:
      govee_strip:
        friendly_name: "Govee Strip"
        turn_on:
          service: input_boolean.turn_on
          entity_id: input_boolean.govee_strip
        turn_off:
          service: input_boolean.turn_off
          entity_id: input_boolean.govee_strip
        set_level:
          service: input_number.set_value
          data_template:
            value: "{{ brightness }}"
            entity_id: input_number.govee_strip
        temperature_template: "{{states('input_number.govee_temperature_input') | int}}"
        set_temperature:
          service: input_number.set_value
          data_template:
            value: "{{ color_temp }}"
            entity_id: input_number.govee_temperature_input
        color_template: "({{states('input_number.govee_h_input') | int}}, {{states('input_number.govee_s_input') | int}})"
        set_color:
          - service: input_number.set_value
            data_template:
              value: "{{ h }}"
              entity_id: input_number.govee_h_input
          - service: input_number.set_value
            data_template:
              value: "{{ s }}"
              entity_id: input_number.govee_s_input

Node Red:

[{"id":"6417e853.f90a58","type":"tab","label":"Govee Strip","disabled":false,"info":""},{"id":"b38dab15.6f7ea8","type":"server-events","z":"6417e853.f90a58","name":"Govee Light Strip","server":"60a5cb09.83c6b4","event_type":"call_service","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":100,"y":220,"wires":[["b3614dc6.0c609"]]},{"id":"b3614dc6.0c609","type":"switch","z":"6417e853.f90a58","name":"Govee Light","property":"payload.event.service_data.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"light.govee_strip","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":220,"wires":[["af7901cf.990f3"]]},{"id":"af7901cf.990f3","type":"switch","z":"6417e853.f90a58","name":"Off / On","property":"payload.event.service","propertyType":"msg","rules":[{"t":"eq","v":"turn_off","vt":"str"},{"t":"eq","v":"turn_on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":420,"y":220,"wires":[["c7322a8f.e8bdb8"],["6a9957eb.61da08"]]},{"id":"c7322a8f.e8bdb8","type":"alexa-remote-smarthome","z":"6417e853.f90a58","name":"Turn Off Desk Light","account":"c48d6174.f6e8c","config":{"option":"action","value":[{"entity":"16c5f063-98e3-4462-98e7-5ed52790bbeb","action":"turnOff"}]},"outputs":1,"x":610,"y":180,"wires":[[]]},{"id":"9f7ab290.d1045","type":"alexa-remote-smarthome","z":"6417e853.f90a58","name":"Desk Brightness","account":"c48d6174.f6e8c","config":{"option":"action","value":[{"entity":"16c5f063-98e3-4462-98e7-5ed52790bbeb","action":"setBrightness","value":{"type":"msg","value":"payload.event.service_data.brightness"}}]},"outputs":1,"x":800,"y":220,"wires":[[]]},{"id":"6a9957eb.61da08","type":"function","z":"6417e853.f90a58","name":"Light Function","func":"if (typeof msg.payload.event.service_data.brightness != \"undefined\" && typeof msg.payload.event.service_data.hs_color != \"undefined\") {\n    var brightness = msg.payload.event.service_data.brightness;\n    var percent = ((brightness * 100) / 255);\n    \n    msg.payload.event.service_data.brightness = percent;\n\n    return [msg, msg, null, null];\n} else if (typeof msg.payload.event.service_data.brightness != \"undefined\" && typeof msg.payload.event.service_data.color_temp != \"undefined\") {\n    var colors_numbers = [150, 222, 278, 361, 433];\n    var color_names = [\"Cool\", \"Daylight\", \"White\", \"Soft\", \"Warm\"];\n    var color = msg.payload.event.service_data.color_temp;\n    var newmsg = {};\n\n    var brightness = msg.payload.event.service_data.brightness;\n    newmsg.payload.brightness = ((brightness * 100) / 255);\n    \n    if (color >= colors_numbers[0] && color < colors_numbers[1]) {\n        newmsg.payload.color = color_names[0];\n    } else if (color >= colors_numbers[1] && color < colors_numbers[2]) {\n        newmsg.payload.color = color_names[1];\n    } else if (color >= colors_numbers[2] && color < colors_numbers[3]) {\n        newmsg.payload.color = color_names[2];\n    }  else if (color >= colors_numbers[3] && color < colors_numbers[4]) {\n        newmsg.payload.color = color_names[3];\n    } else if (color >= colors_numbers[4] && color <= 500) {\n        newmsg.payload.color = color_names[4];\n    }\n    \n    return [newmsg, null, newmsg, null];\n} else if (typeof msg.payload.event.service_data.brightness != \"undefined\") {\n    var brightness = msg.payload.event.service_data.brightness;\n    var percent = ((brightness * 100) / 255);\n    \n    msg.payload.event.service_data.brightness = percent;\n    \n    return [msg, null, null, null];\n} else if (typeof msg.payload.event.service_data.hs_color != \"undefined\") {\n    return [null, msg, null, null];\n} else if (typeof msg.payload.event.service_data.color_temp != \"undefined\") {\n    var colors_numbers = [150, 222, 278, 361, 433];\n    var color_names = [\"Cool\", \"Daylight\", \"White\", \"Soft\", \"Warm\"];\n    var color = msg.payload.event.service_data.color_temp;\n    var newmsg = {};\n    \n    if (color >= colors_numbers[0] && color < colors_numbers[1]) {\n        newmsg.payload.color = color_names[0];\n    } else if (color >= colors_numbers[1] && color < colors_numbers[2]) {\n        newmsg.payload.color = color_names[1];\n    } else if (color >= colors_numbers[2] && color < colors_numbers[3]) {\n        newmsg.payload.color = color_names[2];\n    }  else if (color >= colors_numbers[3] && color < colors_numbers[4]) {\n        newmsg.payload.color = color_names[3];\n    } else if (color >= colors_numbers[4] && color <= 500) {\n        newmsg.payload.color = color_names[4];\n    }\n    \n    return [null, null, newmsg, null];\n}\n\n\nreturn [null, null, null, msg];","outputs":4,"noerr":0,"x":600,"y":280,"wires":[["9f7ab290.d1045"],["ab8a5f76.da31"],["8310ed00.d6e71"],["74269dd7.a9c334"]]},{"id":"f0a449f8.0690f8","type":"color-convert","z":"6417e853.f90a58","input":"hsl","output":"css","outputType":"string","scaleInput":false,"x":970,"y":260,"wires":[["ecdbf6f3.6838d8"]]},{"id":"ab8a5f76.da31","type":"change","z":"6417e853.f90a58","name":"","rules":[{"t":"set","p":"payload.hue","pt":"msg","to":"payload.event.service_data.hs_color[0]","tot":"msg"},{"t":"set","p":"payload.saturation","pt":"msg","to":"payload.event.service_data.hs_color[1]","tot":"msg"},{"t":"set","p":"payload.lightness","pt":"msg","to":"50","tot":"num"},{"t":"delete","p":"payload.event_type","pt":"msg"},{"t":"delete","p":"payload.event","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":260,"wires":[["f0a449f8.0690f8"]]},{"id":"ecdbf6f3.6838d8","type":"alexa-remote-smarthome","z":"6417e853.f90a58","name":"Desk Color","account":"c48d6174.f6e8c","config":{"option":"action","value":[{"entity":"16c5f063-98e3-4462-98e7-5ed52790bbeb","action":"setColor","value":{"type":"msg","value":"payload"}}]},"outputs":1,"x":1130,"y":260,"wires":[[]]},{"id":"8310ed00.d6e71","type":"alexa-remote-smarthome","z":"6417e853.f90a58","name":"Desk Color Temperature","account":"c48d6174.f6e8c","config":{"option":"action","value":[{"entity":"16c5f063-98e3-4462-98e7-5ed52790bbeb","action":"setColorTemperature","value":{"type":"msg","value":"payload.color"}}]},"outputs":1,"x":830,"y":300,"wires":[[]]},{"id":"74269dd7.a9c334","type":"alexa-remote-smarthome","z":"6417e853.f90a58","name":"Desk Turn On","account":"c48d6174.f6e8c","config":{"option":"action","value":[{"entity":"16c5f063-98e3-4462-98e7-5ed52790bbeb","action":"turnOn"}]},"outputs":1,"x":800,"y":340,"wires":[[]]},{"id":"60a5cb09.83c6b4","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"c48d6174.f6e8c","type":"alexa-remote-account","z":"","name":"Main","authMethod":"proxy","proxyOwnIp":"192.168.1.39","proxyPort":"3456","cookieFile":"","refreshInterval":"3","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

Keep in mind you will need to replace the template light.py with the one in the pull request since his PR is not live yet.

Thank you for sharing!

But what do you mean by this?

Ok I found it but i can’t find the light.py from this PR and how to intergrade it to my hassio
Any help would be appreciated!
@tetienne

I would like more info on all this too. Where is the light.py file from the PR? Sorry I am not that familiar with GitHub.

And can we save this as a custom_component? Sounds like its suggested we replace the default light.py file…

I just got one of these today too and need to know the same thing.

Did you make any progress?

Hi,

so far i’m only able to turn on/off LED strip using Home Assistant Relay. I’m using Hass.io and there is an addon with this component.
Govee google assistant integration is very limited, there is only optoon to on/off device (in last used mode), set brightnes and set static color.
As far is i knove Govee is going to extend GA integration capabilities in future.

That’s really all I need to do. Would you mind sharing your solution?

No problem :slight_smile:

  1. Add this custom addon repository to Hass.io: https://github.com/Apipa169/Assistant-Relay-for-Hassio
  2. Install Assistant Relay Addon
  3. Setup addon using web interface - there is step by step wizzard.
  4. When addon is ready you will be able to send text commnads to GA eg. “turn on table light”
  5. Create rest command inside HA
assistant_relay_command:
  url: http://[hassio host name or ip]:3000/assistant
  method: POST
  content_type: 'application/json'
  payload: '{"command":"{{ command }}", "user":"[google email]"}'

then you can use later in automation like this:

    - service: rest_command.assistant_relay_command
      data:
        command: "turn {{state}} tv ambient light"

“tv ambient light” is the name of device inside GA/GH.
I even created a switch for that light:

    salon_tv_ambient_light:
      value_template: '{{ states("input_boolean.salon_tv_ambient_light") }}'
      friendly_name: 'TV ambient light'
      turn_on:
        - service: rest_command.assistant_relay_command
          data:
            command: "turn on tv ambient light"
        - service: input_boolean.turn_on
          entity_id: input_boolean.salon_tv_ambient_light
      turn_off:
        - service: rest_command.assistant_relay_command
          data:
            command: "turn off tv ambient light"
        - service: input_boolean.turn_off
          entity_id: input_boolean.salon_tv_ambient_light

There is one downside of this solution. So far i’m not able to synchronize states between HA and Google. If you turn on the device via Govee app or GA the state inside HA doesn’t change.

Maybe somebody knows a soulution for that case? :slight_smile:

1 Like

Thank you, that’s great. I Already have it working with GA so this should be straightforward.

I’ll be having it turn on when the TV turns on but only when it’s not daytime.

Thanks again.

:thinking: I’m running HA on a Mac and don’t have the addon store so can’t install the assistant relay. Anyone know how to manually install it?

The repo is non-compliant with HACS.

@ashscott Addon is just a wrapper for Assistant Relay application. It’s regular node.js application, so you can setup it manually, please look https://github.com/greghesp/assistant-relay

Here is a link to the file

https://raw.githubusercontent.com/home-assistant/home-assistant/538b45f0793cdfb56dc228facef51c9cce746ed4/homeassistant/components/template/light.py

The best way to do this is to console into the container and run

find / -name light.py

Find out where your template folder and cd into it. Ex: for me it is

cd /usr/src/homeassistant/homeassistant/components/template/

You will need to remove the light.py before you can wget so simply

rm -rf light.py

After that wget the new light.py

wget https://raw.githubusercontent.com/home-assistant/home-assist
ant/538b45f0793cdfb56dc228facef51c9cce746ed4/homeassistant/components/template/light.py

Restart home assistant and there you go.

1 Like

Thank you, Vexlar. I’m not running it in a docker container though, just on my Mac.

If you are running on a mac there must be a file system somewhere right?

Since mac is based on linux, open your terminal and type

find / -name light.py

Do you see the home assistant file system?

Thank you for the help.

As you can see, I have more than a few light.py

1 Like

That is perfect, so you indeed have access to the folder, you need to find the “template” component. so it should be something like

cd /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/template/

Just confirm that is your correct directory by typing

ls

To make sure light.py is in the folder and follow my steps.

Copy my package.yaml for the light template and import my node-red flow. (Make sure to update the home assistant nodes, and also alexa remote 2 node.

In node red you will need the following Palettes

  • node-red-contrib-alexa-remote2
  • node-red-contrib-color-convert
  • node-red-contrib-home-assistant-websocket (Which you should already have)