Govee Appliances (Heaters, Fans, Purifiers)

No, the API was added at the cloud layer, the devices still function the same way.

Does Govee have any updated documentation for the new API? The latest I’ve been able to find is v2.0.0 from back in 2020.

http://developer.govee.com

1 Like

NEW API CALLS:
Here’s the new API calls in case someone can step in and help get going with an integration!

Get List of devices and capabilities:
GET https://openapi.api.govee.com/router/api/v1/user/devices
Headers:
Govee-API-Key: [your API Key]

Control Device:
POST https://openapi.api.govee.com/router/api/v1/device/control
Headers:
govee-api-key: [your API Key]
Content-Type: application/json
Post Data:

{
 "requestId": "uuid",
 "payload": {
   "sku": "H7122",
   "device": "64:9E:D4:AD:00:00:00:00",
   "capability": {
     "type": "devices.capabilities.on_off",
     "instance": "powerSwitch",
     "value": 1
   }
 }
}

Device State:
POST https://openapi.api.govee.com/router/api/v1/device/state
headers:
govee-api-key: [your API Key]
Content-Type: application/json
Post Data:

{
  "requestId": "uuid",
  "payload": {
    "sku": "H7122",
    "device": "64:9E:D4:AD:00:00:00:00"
  }
}
1 Like

Is the Device State working for anyone? Using Curl I’m able to get the list of devices successfully, but trying to get device state is throwing a 500 Internal Server Error.

It’s working perfectly for me try including another ‘Content-Type: application/json’ in the body of your request

I find that some applications are okay with just passing it in the header, other ones like it in the body.

Thanks everyone for all of this info… If you have this working adequately, could you post your full documentation such as your yaml and scripts? I seem to be having some issues getting this to work successfully…

Thank you all for sharing. I haven’t built an integration yet but would be happy to collaborate. Here are the sensor and rest_command I built from the API information provided above.

sensor:
  - platform: rest
    name: bedroom_heater_status
    resource: 'https://openapi.api.govee.com/router/api/v1/device/state'
    headers:
      Content-Type: application/json
      Govee-API-Key: !secret govee-api-key
    payload: '{"requestId": "uuid","payload":{ "sku": "H7135","device": "AA:BB:DD:EE:FF:GG:HH:II"}}'
    method: POST
    verify_ssl: false
    value_template: >
      {% set capabilities = value_json.payload.capabilities %}
      {% set on_off_capability = capabilities | selectattr('type', 'eq', 'devices.capabilities.on_off') | first %}
      {{ on_off_capability.state.value }}

rest_command:
  bedroom_heater_control:
    url: https://openapi.api.govee.com/router/api/v1/device/control
    headers:
      Content-Type: application/json
      Govee-API-Key: !secret govee-api-key
    payload: '{"requestId": "uuid","payload":{ "sku": "{{ model }}", "device": "{{ device }}","capability": { "type": "{{ type }}","instance": "{{ instance }}","value": {{ value }}}}}'
    method: POST
    verify_ssl: false
service: rest_command.bedroom_heater_control
data:
  model: H7135
  device: AA:BB:DD:EE:FF:GG:HH:II
  type: devices.capabilities.on_off
  instance: powerSwitch
  value: 1
1 Like

This is awesome work.
I was going to go a different way for the meantime, if you use a rest switch instead, it can have a control url and a different “is_on_template” url to put both control and status in the same entity.

Dang, I had just looked at that too but didn’t know about the two different url’s. Now readding the docs I see there is a separate resource and state_resource url config. I might give that a try to clean it up.

I played around with the rest switch and don’t think it will work exactly. The state has to use a GET request. I got the switch to load by using the users/devices API url. The switch on and off works but the status doesn’t update because it’s based on a bogus GET request.

Continuing the discussion from Govee Appliances (Heaters, Fans, Purifiers):

Hi, I have a humidifier. The discover request gets this response:

{“sku”:“H7140”,“device”:“xx:xx:xx:xx:xx:xx:xx:xx”,“deviceName”:“humidifier7140”,“type”:“devices.types.humidifier”,“capabilities”:[{“type”:“devices.capabilities.on_off”,“instance”:“powerSwitch”,“parameters”:{“dataType”:“ENUM”,“options”:[{“name”:“on”,“value”:1},{“name”:“off”,“value”:0}]}},{“type”:“devices.capabilities.work_mode”,“instance”:“workMode”,“parameters”:{“dataType”:“STRUCT”,“fields”:[{“fieldName”:“workMode”,“dataType”:“ENUM”,“options”:[{“name”:“Manual”,“value”:1},{“name”:“Custom”,“value”:2},{“name”:“Auto”,“value”:3}],“required”:true},{“fieldName”:“modeValue”,“dataType”:“ENUM”,“options”:[{“name”:“Manual”,“options”:[{“value”:1},{“value”:2},{“value”:3},{“value”:4},{“value”:5},{“value”:6},{“value”:7},{“value”:8},{“value”:9}]},{“defaultValue”:0,“name”:“Custom”},{“defaultValue”:0,“name”:“Auto”}],“required”:false}]}},{“type”:“devices.capabilities.range”,“instance”:“humidity”,“parameters”:{“unit”:“unit.percent”,“dataType”:“INTEGER”,“range”:{“min”:40,“max”:80,“precision”:1}}},{“type”:“devices.capabilities.toggle”,“instance”:“nightlightToggle”,“parameters”:{“dataType”:“ENUM”,“options”:[{“name”:“on”,“value”:1},{“name”:“off”,“value”:0}]}},{“type”:“devices.capabilities.range”,“instance”:“brightness”,“parameters”:{“dataType”:“INTEGER”,“range”:{“min”:1,“max”:100,“precision”:1}}},{“type”:“devices.capabilities.color_setting”,“instance”:“colorRgb”,“parameters”:{“dataType”:“INTEGER”,“range”:{“min”:0,“max”:16777215,“precision”:1}}},{“type”:“devices.capabilities.mode”,“instance”:“nightlightScene”,“parameters”:{“dataType”:“ENUM”,“options”:[{“name”:“Forest”,“value”:1},{“name”:“Ocean”,“value”:2},{“name”:“Wetland”,“value”:3},{“name”:“Leisurely”,“value”:4},{“name”:“Sleep”,“value”:5}]}},{“type”:“devices.capabilities.event”,“instance”:“lackWaterEvent”,“alarmType”:51,“eventState”:{“options”:[{“name”:“lack”,“value”:1,“message”:“Lack of Water”}]}}]}]}

My rest_command:

rest_command:
govee_control:
url: https://openapi.api.govee.com/router/api/v1/device/control
headers:
Content-Type: application/json
Govee-API-Key: !secret govee-api-key
payload: ‘{“requestId”: “uuid”,“payload”:{ “sku”: “{{ model }}”, “device”: “{{ device }}”,“capability”: { “type”: “{{ type }}”,“instance”: “{{ instance }}”,“value”: {{ value }}}}}’
method: POST
verify_ssl: false

I can power on/off the device in ha with this service-call:

service: rest_command.govee_control
data:
device: xx:xx:xx:xx:xx:xx:xx:xx
model: H7140
type: devices.capabilities.on_off
instance: powerSwitch
value: 1

Does anybody know how i can set the workMode and the modeValue in HA?
I dont know the value-part:

service: rest_command.govee_control
data:
device: xx:xx:xx:xx:xx:xx:xx:xx
model: H7140
type: devices.capabilities.work_mode
instance: workMode
value:???

You should be using the get devices option to figure out what your modes are.

It should look something like

           {
                    "type": "devices.capabilities.work_mode",
                    "instance": "workMode",
                    "parameters": {
                        "dataType": "STRUCT",
                        "fields": [
                            {
                                "fieldName": "workMode",
                                "dataType": "ENUM",
                                "options": [
                                    {
                                        "name": "Manual",
                                        "value": 1
                                    },
                                    {
                                        "name": "Custom",
                                        "value": 2
                                    },
                                    {
                                        "name": "Auto",
                                        "value": 3
                                    }
                                ],
                                "required": true
                            },

The value should probably be 1,2, or 3 depending one which workMode you’re trying to put it in.

Hi I tried:
value: 1
value: 2
value: 3
But no reaction.

I think the fieldName ‘workMode’ and the value 1,2 or 3
must be in the valuefield like
value: ‘workMode: 2’ or so

Hello,
if i use Postmann with these body-values
{
“requestId”: “uuid”,
“payload”: {
“sku”: “H7140”,
“device”: “1D:XX:D4:XX:XX:XX:XX:XX”,
“capability”: {
“type”: “devices.capabilities.work_mode”,
“instance”: “workMode”,
“value”: {
“workMode”:1, “modeValue”:6
}
}
}
}

i can control the mode.

in homeassistant in the developer-tools with service call i use:

service: rest_command.govee_control
data:
device: 1D:XX:D4:XX:XX:XX:XX:XX
model: H7140
type: devices.capabilities.work_mode
instance: workMode
value: {
“workMode”:1, “modeValue”:7
}
but i can’t control the device.

where is the mistake?

Someone find how to activate\desactivate the swing ?

I put this in my rest.yaml file:

heater_oscillate_onoff:
  url: https://openapi.api.govee.com/router/api/v1/device/control
  method: POST
  headers:
    Content-Type: application/json
    Govee-API-Key: your-api-key
  content_type: "application/json; charset=utf-8"
  payload: >-
    {
      "requestId": "uuid",
      "payload": {
        "sku": "H7131",
        "device": "deviceID",
        "capability": {
          "type": "devices.capabilities.toggle",
          "instance": "oscillationToggle",
          "value": {{ onoff }}
        }
      }
    }

If you haven’t divided your config up, it’ll be under the ‘rest_command:’ header
Then, when calling the service, supply either a 1 (for on) or a 0 (for off) in the data header under the “onoff” key.
Let me know if you have any questions

1 Like

Hi,

I have the same heater, can you please share the configs and script fot it.

Look at here :

Has anyone with a H7130 model heater been able to get the new API to work? I’ve tried a variety of methods, but I always end up getting a 500 error. The old API works flawlessly (other than it being super limited in functionality).