Strange "Units: C" part in Entity

Hi ALl,

Im using Zwave2Mqtt. Have some door sensors and they also send temperature.
Homekit now complain about a Value:

ValueError: C is not a recognized temperature unit.

sensor.node_13_temperature:
value_id: 101-49-1-1
node_id: 101
class_id: 49
type: decimal
genre: user
instance: 1
index: 1
label: Air Temperature
units: C
help: Air Temperature Sensor Value
read_only: true
write_only: false
min: 0
max: 0
is_polled: false
value: 17.8
lastUpdate: 1588642402824
unit_of_measurement: C
friendly_name: Frontdoor Temp
device_class: temperature
templates:
  icon_color: >-
    if (state > 38) return 'rgb(181,14,2)'; if (state > 32) return
    'rgb(214,18,4)'; if (state > 27) return 'rgb(255,0,0)'; if (state > 21)
    return 'rgb(255,150,0)'; if (state > 16) return 'rgb(255,204,0)'; if (state
    > 10) return 'rgb(0,255,0)'; if (state > 4) return 'rgb(4,181,4)'; if (state
    > -1) return 'rgb(0,170,217)'; if (state > -7) return 'rgb(0,0,255)'; if
    (state > -12) return 'rgb(121,24,196)'; if (state > -18) return
    'rgb(176,0,189)'; if (state > -23) return 'rgb(189,0,107)'; return
    'rgb(0,0,0)';
icon_color: 'rgb(255,204,0)'

But when I check in Zwave2Mqtt I see this JSON payload:

{
  "type": "sensor",
  "object_id": "temperature_air",
  "discovery_payload": {
    "value_template": "{{ value_json.value }}",
    "device_class": "temperature",
    "unit_of_measurement": "C",
    "state_topic": "homeassistant/diningroom/door_imac/49/1/1",
    "json_attributes_topic": "homeassistant/diningroom/door_imac/49/1/1",
    "device": {
      "identifiers": [
        "zwave2mqtt_0xf2a6b7f2_node100"
      ],
      "manufacturer": "FIBARO System",
      "model": "FGDW002 Door Opening Sensor 2 (0x1000)",
      "name": "diningroom-door_imac",
      "sw_version": "Unknown"
    },
    "name": "diningroom-door_imac_temperature_air",
    "unique_id": "zwave2mqtt_0xf2a6b7f2_100-49-1-1"
  },
  "discoveryTopic": "sensor/diningroom-door_imac/temperature_air/config",
  "values": [
    "49-1-1"
  ],
  "persistent": true,
  "id": "sensor_temperature_air"
}

There is no “units: C” but the correct “unit_of_measurement” part

In my customize file I have add some extra things

sensor.node_13_temperature:
  friendly_name: "Door iMac Temp"
  templates:
    icon_color: >-
      if (state > 38) return 'rgb(181,14,2)';
      if (state > 32) return 'rgb(214,18,4)';
      if (state > 27) return 'rgb(255,0,0)';
      if (state > 21) return 'rgb(255,150,0)';
      if (state > 16) return 'rgb(255,204,0)';
      if (state > 10) return 'rgb(0,255,0)';
      if (state > 4) return 'rgb(4,181,4)';
      if (state > -1) return 'rgb(0,170,217)';
      if (state > -7) return 'rgb(0,0,255)';
      if (state > -12) return 'rgb(121,24,196)';
      if (state > -18) return 'rgb(176,0,189)';
      if (state > -23) return 'rgb(189,0,107)';
      return 'rgb(0,0,0)';

Also nothing that will change the class of the device entity.

How can I solve this? The “Units C” break the option to show this entity in Homekit.

If nothing can do, I have to create a sensor template that show the temperature and put that one in Homekit, but thats only a workaround, I don’t like create more sensors if not needed :slight_smile:

This:

    "unit_of_measurement": "C",

Needs to be this:

    "unit_of_measurement": "°C",
1 Like

@tom_l
Maybe you know that as well before I open new topic:

A motion sensor is showing correct in HA
But in Homekit the device is not working

Tried to remove device_class. When I change device_class to “door” then homekit show it as door.
tried it without “” behind motion, didn’t work HA is not working then also.

value_id: 65-48-1-0
node_id: 65
class_id: 48
type: bool
genre: user
instance: 1
index: 0
label: Sensor
units: ''
help: Binary Sensor State
read_only: true
write_only: false
min: 0
max: 0
is_polled: false
value: false
lastUpdate: 1588671285470
friendly_name: PIR Diningroom
device_class: "motion"
templates:
  icon: 'mdi:motion-sensor'
  icon_color: >-
    if (state === 'on') return 'rgba(251, 214, 67,1)'; return
    'rgba(71,116,157,1)';
icon: 'mdi:motion-sensor'
icon_color: 'rgba(71,116,157,1)'

I know very little about Homekit sorry, and I don’t really understand your question.

It’s solved. I did a homekit reset nowy sensors show correct in homekit app in ios