TL;DR wifi power switches are connected, responding to turn_on and turn_off, monitoring Voltage … but mostly not showing the Amps or Watts when turned on !
I’m not even sure whether this is hardware, localTuya or something else
I have added some Arlec PC191HA wifi power switches using localTuya. They show and update the switch status instantly, and show the voltage … but only sometimes show the Amps or watts !
These are all PC191HA switches, and as you can see all currently switched ON. All show a voltage.
At first glance this appears reasonable - switch is connected to voltage even when the devices plugged into the switches are not operating.
However as I write this the heater in the bedroom has been heating the bedroom for 10 minutes, there is no phone plugged into the bedroom charger, pc191ha-107 currently has a desk lamp shining on my desk, and pc191ha-109 is powering a RasPi 1B drawing about 1/2 Amp.
-
For a while i have been assuming that maybe they have been dropping off my wifi, since (a) my study is a poor reception area, and (b) I re-purposed an old wifi router (which i discovered today only allows 15 connected devices) - but I have today been checking the Wireless statistics and the device MAC addresses are connected.
-
Check for faulty hardware. I disabled the router firewall rules to block IoT devices from the internet, and (after a while) the Tuya phone app saw the devices online, and did report power usage as well as the voltage and switch status. So, NOT a hardware fault. Turned the firewall rules back on, and after a while the tuya phone app shows all devices as disconnected.
-
Check the installation. the DP_ID information I previously obtained from the Tuya website is:
Interestingly the HA localTuya integration aslo shows values for additional DP_IDs numbered 21-26 but of course no description.
Lets pick on the switch with the desk lamp connected and IP address ending in 107. The device appears OK
but probably best to show the detail of configuration
clicking [submit] gives the switch details:
Now, i know I could have set up sensors for Current, Consumption and Voltage … but when I tried the first unit I found a forum post which created sensors from attributes in configuration.yaml. But it is such a pain that I copied and pasted the code for the first unit:
sensor:
- platform: template
sensors:
# Arlec PC191HA power switches
# The localTuya integration reports power usage as attributes on the switch entity
# so we need to extract them as individual entities.
# Believe me, doing it this way is better than creating lots of separate
# sensor entities when creating the devices in the integration
...
#
pc191ha_107_voltage:
value_template: "{{ state_attr('switch.pc191ha_107', 'voltage') }}"
unit_of_measurement: 'V'
pc191ha_107_current:
value_template: "{{ state_attr('switch.pc191ha_107', 'current') }}"
unit_of_measurement: 'mA'
pc191ha_107_current_consumption:
value_template: "{{ state_attr('switch.pc191ha_107', 'current_consumption') }}"
unit_of_measurement: 'W'
- OK, that’s how it is configured. So, what is it reporting ? In HA Developer Tools > States we see:
so It looks as though the switch attributes are being translated to separate sensors. Maybe this step is causing a delay ? Probably, but after 10 minutes the fan heater still had registered only Voltage.
Why Voltage has a value, but Current or Consumption are zero ?
To add to the weirdness, today I moved a couple of the units around physically. I decided it would be easier to compare if I was using my TP-Link switches on the fridge and freezers … and the pc191ha-109 was one that was re-purposed. Several of the units (including 107) have physically moved so not a power off/on reset.
I have restarted the integration, and restarted HA … each several times.
Any ideas ? What have i missed ? What else can I check ?