Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The humidity entity status is bad in room card #27

Open
bimbopp opened this issue Oct 7, 2024 · 17 comments
Open

The humidity entity status is bad in room card #27

bimbopp opened this issue Oct 7, 2024 · 17 comments

Comments

@bimbopp
Copy link

bimbopp commented Oct 7, 2024

hello I use your custom room card. I noticed that the state of the humidity thermometers entity was incorrectly displaying humidity. This only happens with zigbee thermometers. Entity status is OK in HA. In Z2M, the condition is also ok. Only on the dashboard it is incorrect.
Snímek obrazovky 2024-10-07 160550

@andyblac
Copy link
Owner

andyblac commented Oct 7, 2024

hi, lets try to investigate this, it can only show the state of what HA has stored, can you go to Developer Tools -> States, find your entity and click on it, what does the state display ?

This is my Aqara Humidity Sensor, it is reporting the correct value.
Screenshot 2024-10-07 at 15 22 33

Screenshot 2024-10-07 at 15 24 02

@bimbopp
Copy link
Author

bimbopp commented Oct 7, 2024

Snímek obrazovky 2024-10-07 164017

@andyblac
Copy link
Owner

andyblac commented Oct 7, 2024

it looks like it is detecting the temperature attribute from the sensor. can you post your room code please.

also what device is it?, as it does not seem to have a device_class or unit_of_measurement

@bimbopp
Copy link
Author

bimbopp commented Oct 7, 2024

Temperature value is correct.
Code :

type: "custom:button-card"
template:
  - custom_card_andyblac_room
name: Pokojík
icon: mdi:chair-rolling
tap_action:
  action: call-service
  service: "input_select.select_option"
  service_data:
    option: "study"
    entity_id: "input_select.minimalist_ui_switch"
variables:
  ulm_custom_card_andyblac_room_use_label_icons: true
  ulm_custom_card_andyblac_room_color: red
  ulm_custom_card_andyblac_room_use_small_room_icon: true
  sensor_label_1: sensor.mi_teplomer_3_temperature
  sensor_label_2: sensor.mi_teplomer_3_humidity

Device: https://www.zigbee2mqtt.io/devices/LYWSD03MMC.html

@andyblac
Copy link
Owner

andyblac commented Oct 7, 2024

hmm, strange can you add the code to your room car, as a test

    label: > 
      [[[
        var entity = 'sensor.mi_teplomer_3_humidity'
        var entity_state = helpers.localize(states[entity], states[entity].state);
        return entity_state;
      ]]]

then refresh the dashboard, using the 3 dots in top right of screen.

@bimbopp
Copy link
Author

bimbopp commented Oct 7, 2024

Yes correct view
Snímek obrazovky 2024-10-07 172206

@andyblac
Copy link
Owner

andyblac commented Oct 7, 2024

thats strange the card is using the same code.

here's a copy of the latest dev, just incase.
custom_card_andyblac_room.yaml.zip

@andyblac
Copy link
Owner

andyblac commented Oct 7, 2024

can you also try with just using sensor_label_1, to see if it does the same.
i.e
sensor_label_1: sensor.mi_teplomer_3_humidity

@bimbopp
Copy link
Author

bimbopp commented Oct 7, 2024

Thank you for your interest and patience.
Unfortunately, even with the latest dev when consuming sensor_label_1 does not have the correct value according to the entity in the developer tool states. It is interesting that it is only a device equipped with zigbee. WiFi devices display the correct value.

@andyblac
Copy link
Owner

andyblac commented Oct 7, 2024

are you using ZHA or Z2M, I'm using Z2M with no issues here.

@bimbopp
Copy link
Author

bimbopp commented Oct 7, 2024

I use Z2M.
I still have these zigbee thermometers: https://www.zigbee2mqtt.io/devices/WSD500A.html with the same behavior.

@andyblac
Copy link
Owner

andyblac commented Oct 7, 2024

@bimbopp
Copy link
Author

bimbopp commented Oct 8, 2024

@bimbopp
Copy link
Author

bimbopp commented Oct 9, 2024

I tried creating a new sensor with device sensor status. When using the new sensor, the display is correct.

@bimbopp
Copy link
Author

bimbopp commented Oct 13, 2024

One more note. In devices where there is temperature in the attributes, temperature will be displayed instead of humidity. In devices where there is neither temperature nor humidity in the attributes, humidity will be displayed. It would probably like the value of the humidity attribute to be in the entity_state variable.

@andyblac
Copy link
Owner

this is the code

  label: |-
    [[[
      var spacer = " | ";
      function getState(entity) {
        var entity_type = "";
        var entity_state = "";
        if (variables.andyblac_card_room_use_label_icons) {
          var entity_type = "| ";
          var spacer = " ";
          if (states[entity].attributes?.device_class == 'temperature') {
            var entity_type = "🌡️";
          } else if (states[entity].attributes?.device_class == 'humidity') {
            var entity_type = "💧";
          } else if (states[entity].attributes?.device_class == 'illuminance') {
            var entity_type = "🔆";
          }
        }
        if (states[entity].attributes?.brightness) {
          var bri = Math.round(states[entity].attributes?.brightness / 2.55);
          var entity_type = "💡";
          var entity_state = (bri ? bri : "0") + "%";
        } else if (states[entity].state) {
          var entity_state = helpers.localize(states[entity], states[entity].state);
        } 
        return entity_type + entity_state;
      }

      if (variables.sensor_label_1 && variables.sensor_label_2 && variables.sensor_label_3) {
        return getState(variables.sensor_label_1) + spacer + getState(variables.sensor_label_2) + spacer + getState(variables.sensor_label_3);
      } else if (variables.sensor_label_1 && variables.sensor_label_2) {
        return getState(variables.sensor_label_1) + spacer + getState(variables.sensor_label_2);
      } else if (variables.sensor_label_1 && variables.sensor_label_3) {
        return getState(variables.sensor_label_1) + spacer + getState(variables.sensor_label_3);
      } else if (variables.sensor_label_2 && variables.sensor_label_3) {
        return getState(variables.sensor_label_2) + spacer + getState(variables.sensor_label_3);
      } else if (variables.sensor_label_1) {
        return getState(variables.sensor_label_1);
      } else if (variables.sensor_label_2) {
        return getState(variables.sensor_label_2);
      } else if (variables.sensor_label_3) {
        return getState(variables.sensor_label_3);
      } else if (entity?.entity_id) {
        return getState(entity.entity_id);
      }
      return variables.ulm_translation_state;
    ]]]

@bimbopp
Copy link
Author

bimbopp commented Oct 13, 2024

Yes, but for some unknown reason the value of the temperature attribute is in entity_state and not the value of the entity state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants