Hi, I can’t make these working in HA. I tried many different configurations, but while I can see the values from my Tuya plug, I can’t see them in the Energy dashboard. My configuration looks like this
I think in the sensor all needs to be lower case?
there is a capital P in:
my-plug.sensor.Plug-current-consumption
you also have dashes instead of underlines.
also, the current consumption value is simply W, not kWh
my sensor is
kitchen_current_consumption:
value_template: "{{ states.switch.kitchen.attributes.current_consumption }}"
device_class: power
unit_of_measurement: 'W'
I don’t use the Energy dash, so can’t help you there.
localtuya:
- host: xx
device_id: xx
local_key: xx
friendly_name: bibe
protocol_version: "3.3"
entities:
- platform: switch
friendly_name: bibe_switch
id: 1
- platform: sensor
friendly_name: bibe_current
device_class: current
id: 18
- platform: sensor
friendly_name: bibe_consumption
device_class: energy
id: 19
- platform: sensor
friendly_name: bibe_voltage
device_class: voltage
id: 20
sensor:
- platform: template
sensors:
bibe_current_template:
friendly_name: "Current"
unit_of_measurement: 'A'
value_template: '{{ states("sensor.plug_current") | float / 10 }}'
device_class: current
bibe_consumption_template:
friendly_name: "Consumption"
unit_of_measurement: 'kWh'
value_template: '{{ states("sensor.plug_consumption") | float / 10 }}'
device_class: energy
bibe_voltage_template:
friendly_name: "Voltage"
unit_of_measurement: 'V'
value_template: '{{ states("sensor.plug_voltage") | float / 10 }}'
device_class: voltage
however, although I can now see the correct values, I can’t add this device in the Energy tab. Any idea on this?
Moreover, I don’t know if I add another localtuya device how can I reference it, since in the templates I have no bibe reference whatsover, which is my identifier.
I would do the configuration directly through config flow (Settings → Integrations → Add Integration → LocalTuya Integration) rather than fiddling around with configuration.yaml for LocalTuya.
Remember to delete the entries for LocalTuya inside configuration.yaml and restart HA before you go the config flow-way!
Been a while since I played with these, but I just realised that my local tuya setup only works if I have internet, which obviously is not really a local setup.
I set up the plugs using the config flow method, then have a consumption template sensor.
Switching on/off works fine, just can’t get the power data when local.
If you split all your integrations up into packages you would have sensors under their own .yaml file. If you have your sensors combined into the configuration.yaml file you would need to add it in there.