Govee integration

Hi Paul. Just try my solution for now. It’s just 1 little tweak in code until the native api is implemented and it works for me like a charm. the file to change is in you’re HA environment. see screenshot below

It’s not the perfect solution but it works for now.

1 Like

@Andre_Mens thanks for the response. After making that change, the light is no longer “unavailable”. However, it also doesn’t work correctly. If I turn on the light via HA, it doesn’t actually turn on and then it is listed as off again in HA (presumably after the API call to get the current state). I’ve included a snippet of the log below that (I think) shows the turn on and then the API saying it’s still off.

2022-08-10 11:10:39.268 DEBUG (MainThread) [govee_api_laggat.api] state returned from API: {'data': {'device': '65:4B:A4:C1:38:B2:29:79', 'model': 'H6160', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'color': {'r': 255, 'b': 0, 'g': 255}}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='65:4B:A4:C1:38:B2:29:79', model='H6160', device_name='Office LED Strip', 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=(255, 255, 0), color_temp=0, timestamp=1660151439.268444, source=<GoveeSource.API: 'api'>, error=None, lock_set_until=1660151351.867474, lock_get_until=1660151352.867501, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False, config_offline_is_off=False)
2022-08-10 11:10:39.269 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.266 seconds (success: True)
2022-08-10 11:10:50.818 DEBUG (MainThread) [custom_components.govee.light] async_turn_on for Govee light 65:4B:A4:C1:38:B2:29:79, kwargs: {}
2022-08-10 11:10:50.819 DEBUG (MainThread) [govee_api_laggat.api] control 65:4B:A4:C1:38:B2:29:79: {'name': 'turn', 'value': 'on'}
2022-08-10 11:10:59.004 DEBUG (MainThread) [custom_components.govee.light] _async_update
2022-08-10 11:10:59.004 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2022-08-10 11:10:59.094 DEBUG (MainThread) [govee_api_laggat.api] state returned from API: {'data': {'device': '65:4B:A4:C1:38:B2:29:79', 'model': 'H6160', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'color': {'r': 255, 'b': 0, 'g': 255}}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='65:4B:A4:C1:38:B2:29:79', model='H6160', device_name='Office LED Strip', 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=(255, 255, 0), color_temp=0, timestamp=1660151459.094414, source=<GoveeSource.API: 'api'>, error=None, lock_set_until=1660151451.918567, lock_get_until=1660151452.9186, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False, config_offline_is_off=False)
2022-08-10 11:10:59.095 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.091 seconds (success: True)
2022-08-10 11:11:19.003 DEBUG (MainThread) [custom_components.govee.light] _async_update
2022-08-10 11:11:19.004 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2022-08-10 11:11:19.276 DEBUG (MainThread) [govee_api_laggat.api] state returned from API: {'data': {'device': '65:4B:A4:C1:38:B2:29:79', 'model': 'H6160', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'color': {'r': 255, 'b': 0, 'g': 255}}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='65:4B:A4:C1:38:B2:29:79', model='H6160', device_name='Office LED Strip', 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=(255, 255, 0), color_temp=0, timestamp=1660151479.275613, source=<GoveeSource.API: 'api'>, error=None, lock_set_until=1660151451.918567, lock_get_until=1660151452.9186, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False, config_offline_is_off=False)
2022-08-10 11:11:19.276 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.274 seconds (success: True)

In this second snippet, I turned the light on with the Govee app (which didn’t register in HA) but then turned it on in HA. I would expect on the next API call that it would see it was on, but it is listed as off (even though it was on at the time). Not sure what to make of that…

2022-08-10 11:15:59.260 DEBUG (MainThread) [govee_api_laggat.api] state returned from API: {'data': {'device': '65:4B:A4:C1:38:B2:29:79', 'model': 'H6160', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'color': {'r': 255, 'b': 0, 'g': 255}}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='65:4B:A4:C1:38:B2:29:79', model='H6160', device_name='Office LED Strip', 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=(255, 255, 0), color_temp=0, timestamp=1660151759.260025, source=<GoveeSource.API: 'api'>, error=None, lock_set_until=1660151451.918567, lock_get_until=1660151452.9186, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False, config_offline_is_off=False)
2022-08-10 11:15:59.261 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.255 seconds (success: True)
2022-08-10 11:16:16.338 DEBUG (MainThread) [custom_components.govee.light] async_turn_on for Govee light 65:4B:A4:C1:38:B2:29:79, kwargs: {}
2022-08-10 11:16:16.340 DEBUG (MainThread) [govee_api_laggat.api] control 65:4B:A4:C1:38:B2:29:79: {'name': 'turn', 'value': 'on'}
2022-08-10 11:16:19.002 DEBUG (MainThread) [custom_components.govee.light] _async_update
2022-08-10 11:16:19.002 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2022-08-10 11:16:19.080 DEBUG (MainThread) [govee_api_laggat.api] state returned from API: {'data': {'device': '65:4B:A4:C1:38:B2:29:79', 'model': 'H6160', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'color': {'r': 255, 'b': 0, 'g': 255}}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='65:4B:A4:C1:38:B2:29:79', model='H6160', device_name='Office LED Strip', 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=(255, 255, 0), color_temp=0, timestamp=1660151779.080216, source=<GoveeSource.API: 'api'>, error=None, lock_set_until=1660151777.626942, lock_get_until=1660151778.626981, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False, config_offline_is_off=False)
2022-08-10 11:16:19.081 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.079 seconds (success: True)
2022-08-10 11:16:39.003 DEBUG (MainThread) [custom_components.govee.light] _async_update
2022-08-10 11:16:39.003 DEBUG (MainThread) [govee_api_laggat.govee_api_laggat] get_states
2022-08-10 11:16:39.267 DEBUG (MainThread) [govee_api_laggat.api] state returned from API: {'data': {'device': '65:4B:A4:C1:38:B2:29:79', 'model': 'H6160', 'properties': [{'online': 'false'}, {'powerState': 'off'}, {'brightness': 100}, {'color': {'r': 255, 'b': 0, 'g': 255}}]}, 'message': 'Success', 'code': 200}, resulting state object: GoveeDevice(device='65:4B:A4:C1:38:B2:29:79', model='H6160', device_name='Office LED Strip', 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=(255, 255, 0), color_temp=0, timestamp=1660151799.267288, source=<GoveeSource.API: 'api'>, error=None, lock_set_until=1660151777.626942, lock_get_until=1660151778.626981, learned_set_brightness_max=100, learned_get_brightness_max=100, before_set_brightness_turn_on=False, config_offline_is_off=False)
2022-08-10 11:16:39.268 DEBUG (MainThread) [custom_components.govee.light] Finished fetching govee data in 0.265 seconds (success: True)

Let me know if there is additional information I can provide.

Thanks!
Paul

Hi Paul

Could you test the API with Visual Studio Code as mentioned in a previous message of me. Then you can see what the API is responding on your calls.

Perhaps setting the polling time a bit higher and setting a new API key can solve a bit.

Greeting Andre

@Andre_Mens Okay, I used your commands and got the following responses:

Request #1:

{
  "data": {
    "devices": [
      {
        "device": "MY-DEVICE-ID",
        "model": "H6160",
        "deviceName": "Office LED Strip",
        "controllable": true,
        "retrievable": true,
        "supportCmds": [
          "turn",
          "brightness",
          "color",
          "colorTem"
        ],
        "properties": {
          "colorTem": {
            "range": {
              "min": 2000,
              "max": 9000
            }
          }
        }
      }
    ]
  },
  "message": "Success",
  "code": 200
}

Request #2:

{
  "data": {
    "device": "MY-DEVICE-ID",
    "model": "H6160",
    "properties": [
      {
        "online": "false"
      },
      {
        "powerState": "off"
      },
      {
        "brightness": 100
      },
      {
        "color": {
          "r": 255,
          "b": 0,
          "g": 255
        }
      }
    ]
  },
  "message": "Success",
  "code": 200
}

Request #3 (Turn On):

{
  "code": 200,
  "message": "Success",
  "data": {}
}

Request #4 (Turn Off):

{
  "code": 200,
  "message": "Success",
  "data": {}
}

But the last two do not turn on or off the light. I also tried the above second Request with the light on and got the same result (that the powerState was off). I’m guessing the “online : false” is the problem?

I had the polling time set to 20 already and tried again with 40. Also, after initial testing with the same result, I requested a new API Key and retested with the above results.

Again, the Govee app works fine for controlling the light, so not sure what is wrong. However, I do notice that when I use the app, it starts out showing the light as “Connection Failed” and then after a few seconds either switches to “Connected” or (maybe 50% of the time) gives a “Reconnect” button (but always connects successfully after a "Reconnect). I don’t know if this is normal behavior since I didn’t use the App before since the HA integration worked correctly up til this month.

So, presumably, this is a Govee problem since the API is returning erroneous information.

Thanks much!
Paul

Andre,

Given the issue I saw with the API saying it was not online, I did some research online and found this Reddit Thread that provided some troubleshooting steps.

I didn’t follow all of them, but I deleted the light from the app, uninstalled the app and reinstalled it. I then logged in to Govee and added the light again.

After that, I again re-ran the API tests and this time it said online : true and I was able to turn the lights on and off.

After putting in the changed API Key in the Govee Integration (since I requested a new one as part of the API testing) and restarting HA, everything is working again!

Thanks for the troubleshooting tips and sorry that I made you go through this when it was a Govee problem and not an Integration problem.

Thanks so much!
Paul

Hi Paul cool you’ve got it working. So now users of the Govee plugin can try you’re finding also to get their problem fixed. Hope the native API wil fix these problems for us. I’m just a user like you and look at the community here to find help for problems. The more ways to find the problems the better it get. Thx for your feedback.

Any plans for their BT/Wi-Fi kettle?

2 Likes

Hi @LaggAt,

Local API available:-

https://app-h5.govee.com/user-manual/wlan-guide?updateTime=181

Came out via twitter a few days ago.

Phill.

3 Likes

This is a great step forward! Unfortunately none of my products are included. Hopefully they keep adding support for more products soon…

1 Like

Me too, at least, the documentation says like this, finger crossed

I have the H6117, which is on the supported list, but I don’t have the LAN Control option for it using the latest version of the app (iOS 5.2.2) and latest firmware for that model. Hopefully that will change soon.

They might be releasing this gradually?? Just a speculation

I have the H6072 from the list and I do have the LAN control button. I had to download a new govee update for each of these lamps. I don’t know what to do next but it certainly looks like the pieces are starting to manifest. None of my other govee products are supported yet according to the list.

I’m on Android and there’s a weird delay for the LAN button to show up on the screen. After you’ve gotten the new light firmware, go to the device setting screen and wait 5-10 seconds, then the screen will update with the LAN slider and whatever your selection was. It appears to be retaining the slider value but there’s definitely a repeatable delay of 5-10 seconds in the govee app screen when looking for this setting.

Apple definitely doesn’t release across the country at once. They throttle the software I work on when we have monthly update. Our customers can see those updates become available usually sometime within 3 days but there’s definitely a staggering when they make a new app version available.

I’ve installed the Govee HACS integration and when trying to add an integration I only see ‘Govee Bluetooth’. Is that the HACS integration? As it cannot find anything (perhaps my model is not supported) but also points to an official HA integration?

I have transitioned to the official integration in preparation for whats to come. With the Bluetooth adapter on, I restarted and it found my 8 devices.

But the official Govee Bluetooth integretion only supports some thermometers right now…

You have 8 thermometers? Or is it now working with LED strips / bulbs / plugs, etc?

I think the Bluetooth integration is great for Bluetooth only devices but for WiFi enabled devices the new local API is 100% the way to go…

They are all lights. I too am waiting on the API for more functionality. I have govee fans that only work with alexa.

Fantastic news, thanks for the share. Unfortunately my H6003 and H6008 are still not supported. Which makes my smart lights NOT USEABLE. I have a set of 4 H6008 and 4 H6003, and just turning them on and off a few times with HA and Nabu Casa commands, it just disconnects. I don’t get it, these used to work flawlessly.

Thanks for this integration. Picked up a Dreamview T1 and experimenting with it now. It shows up as a light in HA, but whenever it’s toggled, it goes to the static colour mode instead of the last mode. Would love to be able to have it toggle back on in “Video” mode if possible. Has anyone achieved this?

EDIT: Seem to have resolved by not using Scenes with Devices, but rather just turning the entity on and off.

1 Like