Govee integration

Hi, feature is complete.
You can enable this in govee_learning.yaml:

40:83:FF:FF:FF:FF:FF:FF:
  .....
  before_set_brightness_turn_on: true

The client will then send a turn on command before every brightness command, if brightness > 0.

2020-10-21 19:14:36 DEBUG (MainThread) [homeassistant.components.govee.light] async_turn_on for Govee light 40:83:FF:FF:FF:FF:FF:FF, kwargs: {'brightness': 23}
2020-10-21 19:14:36 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] control 40:83:FF:FF:FF:FF:FF:FF: {'name': 'turn', 'value': 'on'}
2020-10-21 19:14:36 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 93 in 14.589687824249268 seconds
2020-10-21 19:14:36 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] control 40:83:FF:FF:FF:FF:FF:FF: {'name': 'brightness', 'value': 8}
2020-10-21 19:14:36 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 91 in 10.825117111206055 seconds

other news
For the rest of us, this version has better calculated brightness values, which avoids the jumping slider when live data arrives. This is done by setting the expected brightness value on setting brightness.

This is also updated in the PR.

Meanwhile, get it from here:

I cannot get Samba to work so I tried to FTP the files to my Home Assistant installation.
I successfully connected and when I do I see 2 folders. ā€œShareā€ and ā€œMediaā€. I created a config folder and created a custom_components folder inside of that and then a Govee folder inside of that one and I transferred the files from your zip over.

I have waited for well over an hour and the ā€œGoveeā€ integration never shows up. :frowning: If I disconnect the ftp connection and reconnect the folders and files I created are missing.

Very frustrated as I tried to get Samba working all day to no avail. Iā€™ve watched several videos and followed them and still no luck.

Any ideas??? I really want to be able to control my Govee Dreamcolor LED strip.

1 Like

Just a quick "thanks!ā€™ for this. I have a H6104 mostly used for the ambiance on our TV. All I really needed to do was automate turning it off and on along with the TV and your integration works perfectly for this!

1 Like

Man I just read through the Govee API spec, its a shame we dont have control over all of the modes in the API that they publish.

@LaggAt for this component do you want to stick to only the supported API methods they provide? Iā€™m thinking to do a MITM proxy to see what the other modes we could potentially call that they dont expose in the API.

Also I think there is a bug somewher for my H6117, the brightness jumps from max brightness to around the middle, going to try to see whats causing it. Itā€™s been a while since Iā€™ve done development for home assistant so I need to setup my docker environment.

1 Like

@LaggAt I think I see whats causing the issue, for some reason my H6117 reports a different get and set max in the learned file.

set_brightness_max: 100
get_brightness_max: 254

When its doing division in the python library it has 100 // 254, which is 39%. I added an issue in the library for now until I can download and run the code.

1 Like

Success!
I found the error I was making. I did not have ā€œconfigā€ set to ā€œtrueā€ in the ftp config. I corrected that and was able to successfully ftp the files to HA.
After a while the integration was available. Just waiting on my API key now.

@LaggAt Thank you for your work!

1 Like

I seem to be getting flooded with the following log entry (1449 occurrences in 4 hours)ā€¦
I have the Govee H6195

Logger: govee_api_laggat.govee_api_laggat
Source: /usr/local/lib/python3.8/site-packages/govee_api_laggat/govee_api_laggat.py:579 
First occurred: 6:17:07 PM (1449 occurrences) 
Last logged: 10:18:27 PM

unknown state property {'colorTemInKelvin': 2000}
1 Like

Great you did find it. API key came seconds after requesting it here, so you may check if you requested it successfully.

Well, yes and no. For now I call it done, and use my time for another project. We could do more over bluetooth, and this would also avoid hitting an public api, but Iā€™m not coding that now. Maybe we discover a good govee bluetooth client in PyPi or find some time to write and integrate one sometime.

Hm ā€¦ this is why there is that learning file, I try to find the correct ranges after some brightness control and state requests. I couldā€™ve broke something here with the latest version, as I fixed rounded brightness values.
Could you provide debug logs (described in the first post) AFTER deleting the govee_learning.yaml (or the contents for the specific led) and restarting? Please also set brightness to some levels between min and max. Dont forget to mask your personal data as MAC addresses.Thanks.

Is this with the latest version? With that line number you are in the method setting color, thereā€™s nothing with color temperature. I also like to see the debug logs here, could you enable these for a short time? See first post. Also remember to replace private data as you mac address. Thanks.

Ah forget the logs, i can reproduce this. Iā€™ll check this when I get back from work.

For the H6117, are you using the

  before_set_brightness_turn_on: true

If yes, is there an issue not turning on when setting brightness? This should only be true in this one case.

Iā€™m asking, because I get that described jumping only if I turn this on. If you get this behavour with false here I would need logs :slight_smile:

I didnā€™t see that setting as an options until you just mention it. Iā€™ll set it and try it when I get home.

I was setting the brightness via an entity slider on a dashboard page. It did it regardless of the value I sent. It would scale back because of the division math.

1 Like

Well, this should be off anyway if you didnā€™t configure it, so screw that.
Iā€™m haunting a bug when this setting is true, where the set brightness request somehow fails and doesnā€™t give me an error.

Iā€™ll stop for today, maybe you could do some commented logs which would maybe help. Thanks.

To be honest im not sure which version Iā€™m running here if its the latest one you uploaded. I did just clone your repo and will be testing things myself a bit tonight.

2020-10-22 19:27:58 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] control MACADDRESS: {'name': 'turn', 'value': 'off'}
2020-10-22 19:27:59 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 95 in 5.950536012649536 seconds
2020-10-22 19:28:02 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] control MACADDRESS: {'name': 'brightness', 'value': 100}
2020-10-22 19:28:02 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 98 in 42.87012195587158 seconds
2020-10-22 19:28:05 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2020-10-22 19:28:05 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 94 in -0.03627800941467285 seconds
2020-10-22 19:28:05 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] state returned from API: {'data': {'device': 'MACADDRESS', 'model': 'H6117', 'properties': [{'online': True}, {'powerState': 'on'}, {'brightness': 100}, {'color': {'r': 255, 'b': 255, 'g': 255}}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='MACADDRESS', model='H6117', device_name='Tv Light', controllable=True, retrievable=True, support_cmds=['turn', 'brightness', 'color', 'colorTem'], support_turn=True, support_brightness=True, support_color=True, support_color_tem=True, online=True, power_state=True, brightness=100, color=(255, 255, 255), timestamp=1603409285.060877, source='api', error=None, lock_set_until=0, lock_get_until=1603409284.153718, learned_set_brightness_max=100, learned_get_brightness_max=254)


min_mireds: 2000
max_mireds: 9000
brightness: 101
hs_color:
  - 0
  - 0
rgb_color:
  - 255
  - 255
  - 255
xy_color:
  - 0.323
  - 0.329
rate_limit_total: 100
rate_limit_remaining: 99
rate_limit_reset_seconds: 59.95768618583679
rate_limit_reset: 1603409455.027311
rate_limit_on: 5
manufacturer: Govee
model: H6117
friendly_name: Tv Light
supported_features: 19

image

1 Like

Hmmmm interestingly, when I run the code from your repo in docker, the issue does not present itself, and the learning file is properly set each value is 100 and 100.

I used the latest version directly from your repo and now it seems to be setting it to 100 and the brightness doesnt jump around! Nice!

1 Like

I updated to yesterdays build and the error is still persistent.

Logger: govee_api_laggat.govee_api_laggat
Source: /usr/local/lib/python3.8/site-packages/govee_api_laggat/govee_api_laggat.py:697
First occurred: 8:09:43 PM (25 occurrences)
Last logged: 8:13:45 PM

unknown state property {'colorTemInKelvin': 2000}

Here are the full logs, it seems to be every 10 secondsā€¦

2020-10-22 20:15:25 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.046 seconds
2020-10-22 20:15:35 DEBUG (MainThread) [custom_components.govee.light] _async_update
2020-10-22 20:15:35 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2020-10-22 20:15:35 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 99 in 59.95292401313782 seconds
2020-10-22 20:15:35 WARNING (MainThread) [govee_api_laggat.govee_api_laggat] unknown state property {'colorTemInKelvin': 2000}
2020-10-22 20:15:35 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] state returned from API: {'data': {'device': '52:3C:A4:C1:XX:XX:XX:XX', 'model': 'H6195', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'colorTemInKelvin': 2000}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='52:3C:A4:C1:XX:XX:XX:XX', model='H6195', device_name='MAIN', controllable=True, retrievable=True, support_cmds=['turn', 'brightness', 'color', 'colorTem'], support_turn=True, support_brightness=True, support_color=True, support_color_tem=True, online='false', power_state=False, brightness=254, color=(0, 0, 0), timestamp=1603412135.059321, source='api', error=None, lock_set_until=0, lock_get_until=0, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False)
2020-10-22 20:15:35 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.059 seconds
2020-10-22 20:15:45 DEBUG (MainThread) [custom_components.govee.light] _async_update
2020-10-22 20:15:45 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2020-10-22 20:15:45 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 98 in 49.882776975631714 seconds
2020-10-22 20:15:45 WARNING (MainThread) [govee_api_laggat.govee_api_laggat] unknown state property {'colorTemInKelvin': 2000}
2020-10-22 20:15:45 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] state returned from API: {'data': {'device': '52:3C:A4:C1:XX:XX:XX:XX', 'model': 'H6195', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'colorTemInKelvin': 2000}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='52:3C:A4:C1:XX:XX:XX:XX', model='H6195', device_name='MAIN', controllable=True, retrievable=True, support_cmds=['turn', 'brightness', 'color', 'colorTem'], support_turn=True, support_brightness=True, support_color=True, support_color_tem=True, online='false', power_state=False, brightness=254, color=(0, 0, 0), timestamp=1603412145.129486, source='api', error=None, lock_set_until=0, lock_get_until=0, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False)
2020-10-22 20:15:45 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.127 seconds
2020-10-22 20:15:55 DEBUG (MainThread) [custom_components.govee.light] _async_update
2020-10-22 20:15:55 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2020-10-22 20:15:55 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] Rate limit total: 100, remaining: 99 in 59.96170783042908 seconds
2020-10-22 20:15:55 WARNING (MainThread) [govee_api_laggat.govee_api_laggat] unknown state property {'colorTemInKelvin': 2000}
2020-10-22 20:15:55 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] state returned from API: {'data': {'device': '52:3C:A4:C1:XX:XX:XX:XX', 'model': 'H6195', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'colorTemInKelvin': 2000}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='52:3C:A4:C1:XX:XX:XX:XX', model='H6195', device_name='MAIN', controllable=True, retrievable=True, support_cmds=['turn', 'brightness', 'color', 'colorTem'], support_turn=True, support_brightness=True, support_color=True, support_color_tem=True, online='false', power_state=False, brightness=254, color=(0, 0, 0), timestamp=1603412155.065953, source='api', error=None, lock_set_until=0, lock_get_until=0, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False)

Seems like the python library is not expecting this property and it throws it as a warning. The homeassistant component is hardcoded for the whiteness temp, so it doesnt really matter.

You should just be able to ignore the error based on what I see in the api.

@disforw Correct, as @jesse-schein already stated the lib doesnā€™t know about that state.
writing that as warning isnā€™t nice, but could be ignored for now.

I added an issue for supporting this state attribute (so that you could use it in Node-Red or whatever, as Iā€™m not at home this weekend Iā€™ll probably do this next week.

Hm, seems the feature is broke from the beginning, Iā€™m sorry for that.
I opened a bug to fix this, seems the brightness set doesnā€™t work here.