How to add voltage entity to xiaomi zigbee EU plug?

Hi,
I have installed and worked with Home Assistant on a raspberry pi for few days now. Just added some aqara zigbee devices via Zigbee2MQTT (fw 1.17.1) addon and all is working well, but the power plug is missing the voltage entity (I can see the voltage so the power plug is sending the info but it was not added as an separate entity).

Is there any way to manually add an entity to this device ?
Something like “sensor.0x00131d0001a16fb2_voltage”, “voltage”

Some info from device:
Zigbee model lumi.plug
Description Mi power plug ZigBee
Support status Supported
Firmware build date 02-28-2017
Vendor Xiaomi
Model ZNCZ02LM
Power source Battery
Interview completed Yes

Thank you.

I have to thank all developers of HassOS. Thank you.

I solved the problem by clicking the Developer Tools and in STATES tab, I simply added the new entity with the missing value. Now I have the voltage too.

Thank you for this forum.
Daniel M.

another question to this thread:

After I add the entity to States in dev tools, if I restart the server, the entity is not saved.
Can you tell me how to save the entity after creating it manually ?

What do you mean you added it manually?

I have a xiaomi zigbee plug added to my raspberry pi via zigbee2mqtt
If I go to zigbee2mqtt and select this plug and then choose STATE tab I can see
{
“consumption”: 0.37,
“energy”: 0.37,
“linkquality”: 94,
“power”: 0,
“power_outage_memory”: true,
“state”: “OFF”,
“temperature”: 26,
“voltage”: 234
}

However if I go to the Configuration / Entities it will not display an entity for voltage on this plug (the plug is providing the information)

So under Developer Tools under the STATES tab I clicked on an entity from this plug:
sensor.bucatarie_priza_1_temperature

Then I changed on top of the page
Entity:
sensor.bucatarie_priza_1_voltage

State:
0

State attributes (YAML, optional)
consumption: 0.37
energy: 0.37
linkquality: 94
power: 0
state: ‘OFF’
temperature: 28
voltage: 234
unit_of_measurement: V
friendly_name: bucatarie.priza.1 voltage
device_class: voltage

After this I press SET STATE

After this, I can see the new entity for voltage but if I restart server all is lost

I have already added:to /config/configuration.yaml
homeassistant:
customize: !include customize.yaml

and to /config/customize.yaml
sensor.bucatarie_priza_1_voltage:
device_class: voltage

You should have a sensor XXX_voltage, where XXX is your device name

image

I can not find it (the name should be sensor.bucatarie_priza_1_voltage)
This is why I need to create it myself (the plug sends the voltage value)

That’s not how you add entities. If you want a separate entity for the voltage, you need to configure a template sensor in configuration.yaml (or sensors.yaml or in a package, don’t know how you set it up).

This would create a new entity called sensor.bucatarie_priza_1_voltage

sensor:
  - platform: template
    sensors:
      bucatarie_priza_1_voltage:
        friendly_name: "Bucatarie Priza 1 Voltage"
        unit_of_measurement: "V"
        device_class: voltage
        value_template: "{{ state_attr('sensor.bucatarie_priza_1_temperature', 'voltage') }}"

Thank you, I will try it.

Are you using auto-discovery in Zigbee2MQTT ? If not, use the template that Burningstone suggested.

First I must mention that I am new (2 weeks in touch with Home Assistant). :slight_smile: So I did use auto-discovery in zigbee2mqtt.
I wish I knew how to manually add this voltage entity in the devices that zigbee2mqtt discovered. It is important for me to know when voltage drops under 190v and I was lucky to get one xiaomi plug that shows the voltage.value but unfortunaelly, I think that developers of this plugin did not implement voltage component since only few plugs provide it…

I don’t understand what you are talking about, your plug shows voltage, it’s just not a separate entity but instead an attribute of an entity. I showed you above how you can extract the voltage and get a separate emtity for the voltage.

I have tried that and after restarting server, when I try to use the sensor I see:
Entity is non-numeric: sensor.bucatarie_priza_1_voltage

I also found that I forgot one: ’
It apears to be working now. Will report in few minutes.

If you still get the non-numeric error,try changing the value_template to this:

value_template: "{{ state_attr('sensor.bucatarie_priza_1_temperature', 'voltage')|int }}"

already used that value and so far it is working (waiting for the voltage value to change to make shure)

Thank you.

it is working well. Thank you again :slight_smile: