plasticrake / homebridge-tplink-smarthome

TP-Link Smarthome Plugin for Homebridge
MIT License
474 stars 70 forks source link

tp-link hs110 show power consumption #198

Open schleyk opened 3 years ago

schleyk commented 3 years ago

Expected Behavior

It is possible to extract the power consumption value from the following device?

Current Behavior

On / Off working fine.

Steps to Reproduce (for bugs)

Versions

Configuration

{
    "name": "TplinkSmarthome",
    "addCustomCharacteristics": true,
    "deviceTypes": [
        "plug",
        "bulb"
    ],
    "platform": "TplinkSmarthome"
}

Homebridge Log / Command Output

[5/19/2021, 5:18:40 AM] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Volts': Characteristic not in required or optional characteristic section for service Outlet. Adding anyway.. See https://git.io/JtMGR for more info.
[5/19/2021, 6:20:27 AM] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Consumption': characteristic was supplied illegal value: number 88510.353 exceeded maximum of 65535. See https://git.io/JtMGR for more info.
[5/19/2021, 5:25:30 AM] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Apparent Power': Characteristic not in required or optional characteristic section for service Outlet. Adding anyway.. See https://git.io/JtMGR for more info.

######

tplink-smarthome-api getInfo -D 10.0.2.54
Sending getInfo command to 10.0.2.54:  via tcp...
client.getDevice({"deviceOptions":{"host":"10.0.2.54"}})
client.getSysInfo({"host":"10.0.2.54","port":9999})
TplinkConnection(TCP 10.0.2.54:9999).send({"payload":"{\"system\":{\"get_sysinfo\":{}}}","timeout":10000})
TcpConnection(TCP 10.0.2.54:9999).getSocket()
[1] TplinkSocket(TCP).createSocket()
[1] TplinkSocket(TCP).send({"payload":"{\"system\":{\"get_sysinfo\":{}}}","port":9999,"host":"10.0.2.54","timeout":10000})
[1] TcpSocket: socket:send payload.length 33
[1] TcpSocket: socket:send attempting to connect. host:10.0.2.54, port:9999
[1] TcpSocket: socket:connect 10.0.2.253 56360 10.0.2.54 9999
[1] TcpSocket: socket:connect:write flushed
[1] TcpSocket: socket:data: segment:1 589/589 [{"system":{"get_sysinfo":{"sw_ver":"1.0.5 Build 200917 Rel.095551","hw_ver":"4.0","model":"HS110(EU)","deviceId":"xxxxxxxxxxxxxxxxxx","oemId":"xxxxxxxxxxxxxxxxxx","hwId":"xxxxxxxxxxxxxxxxxx","rssi":-40,"longitude_i":99628,"latitude_i":483650,"alias":"Strom-01","status":"new","mic_type":"IOT.SMARTPLUGSWITCH","feature":"TIM:ENE","mac":"xxxxxxxxxxxxxxxxxx","updating":0,"led_off"                                                                                :0,"relay_state":1,"on_time":57,"active_mode":"none","icon_hash":"","dev_name":"Smart Wi-Fi Plug With Energy Monitoring","next_action":{"type":-1},"err_code":0}}}]
[1] TcpSocket: socket:close, hadError:false
[1] TplinkSocket(TCP).close()
TplinkConnection(TCP 10.0.2.54:9999).close()
device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.0.5 Build 200917 Rel.095551","hw_ver":"4.0","model":"HS110(EU)","deviceId":"xxxxxxxxxxxxxxxxxx","oemId":"xxxxxxxxxxxxxxxxxx","hwId":"xxxxxxxxxxxxxxxxxx","rssi":-40,"longitude_i":99628,"latitude_i":483650,"alias":"Strom-01","status":"new","mic_type":"IOT.SMARTPLUGSWITCH","feature":"TIM:ENE","mac":"xxxxxxxxxxxxxxxxxx","updating":0,"led_off":0,"relay_state":1,"                                                                                on_time":57,"active_mode":"none","icon_hash":"","dev_name":"Smart Wi-Fi Plug With Energy Monitoring","next_action":{"type":-1},"err_code":0},"host":"10.0.2.54","defaultSendOptions":{"timeout":10000,"transport":"tcp","useSharedSocket":fal                                                                                se,"sharedSocketTimeout":20000}})
plug.constructor()
[Strom-01] device sysInfo set
[Strom-01] plug sysInfo set
[Strom-01] plug.emitEvents() inUse: true relayState: true lastState: {"inUse":false,"relayState":false}
Error:
TypeError: Found non-callable @@iterator
    at sendCommandDynamic (/usr/local/lib/node_modules/tplink-smarthome-api/lib/cli.js:112:46)
    at process._tickCallback (internal/process/next_tick.js:68:7)
PlatGitHub468 commented 3 years ago

I see the same issue using V6.4.0 of this plugin.

[07/08/2021, 08:39:02] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Amperes': Characteristic not in required or optional characteristic section for service Outlet. Adding anyway.. See https://git.io/JtMGR for more info. [07/08/2021, 08:39:02] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Total Consumption': Characteristic not in required or optional characteristic section for service Outlet. Adding anyway.. See https://git.io/JtMGR for more info. [07/08/2021, 08:39:02] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Apparent Power': Characteristic not in required or optional characteristic section for service Outlet. Adding anyway.. See https://git.io/JtMGR for more info. [07/08/2021, 08:39:02] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Volts': Characteristic not in required or optional characteristic section for service Outlet. Adding anyway.. See https://git.io/JtMGR for more info. [07/08/2021, 08:39:02] [homebridge-tplink-smarthome] This plugin generated a warning from the characteristic 'Consumption': Characteristic not in required or optional characteristic section for service Outlet. Adding anyway.. See https://git.io/JtMGR for more info.

plasticrake commented 2 years ago

Those warnings are fine. HS110 should show power characteristics but nothing you've provided shows that it is not working.