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

P100 not being polled for power state #56

Closed
PaulHaldane opened this issue Oct 16, 2024 · 1 comment · Fixed by #57
Closed

P100 not being polled for power state #56

PaulHaldane opened this issue Oct 16, 2024 · 1 comment · Fixed by #57
Labels
bug Something isn't working

Comments

@PaulHaldane
Copy link

As far as I can tell the tapo-p100 plugin isn't polling the plugs to check on current power state. Power control works but if the plug's power state is changed externally this isn't reflected in Homebridge (at least not until Homebridge is restarted).

To Reproduce:

  1. Configure at least one P100 in tapo-p100 plugin
  2. Turn on debug mode in Homebridge interface (problem happens without this but useful for showing behaviour)
  3. Plugs will show up up in Homebridge interface with correct power state (as of last restart) and you can change the power state using the interface as expected
  4. Use the manual button on the plug to change power state.
  5. This change isn't reflected in Homebridge interface.

Whilst testing this I was using tcpdump on the host running Homebridge to look for traffic to/from the plugs and once it had got the plug's state at startup there was no more traffic (unless I used the Homebridge interface to change the power state).

Expected behavior:

I expected that the changed power state would be reflected (after some delay) in the Homebridge interface.

Logs:

Before running this test I removed two of the plugs from the config (using the plugin's interface) to keep things slightly simpler.


[16/10/2024, 20:54:19] [Tapo Smart Platform] Initializing TapoP100 platform...
[16/10/2024, 20:54:19] [Tapo Smart Platform] config.json: {"name":"Tapo Smart Platform","username":"[email protected]","password":"XXXXXX-XXXXXX-XXXXXX","devices":[{"name":"smart plug 1","host":"192.168.1.88","type":"Plug","updateInterval":9,"timeout":2}],"platform":"TapoP100"}
[16/10/2024, 20:54:19] [Tapo Smart Platform] config: {"name":"Tapo Smart Platform","username":"[email protected]","password":"XXXXXX-XXXXXX-XXXXXX","waitTimeUpdate":100,"defaultSendOptions":{"timeout":15000},"discoveryOptions":{"discoveryInterval":10000,"deviceOptions":{"defaultSendOptions":{"timeout":15000}},"devices":[{"name":"smart plug 1","host":"192.168.1.88","type":"Plug","updateInterval":9,"timeout":2}]}}
[16/10/2024, 20:54:19] [Tapo Smart Platform] Finished initializing platform: Tapo Smart Platform
[16/10/2024, 20:54:19] [Tapo Smart Platform] Loading accessory from cache: smart plug 1
[16/10/2024, 20:54:19] [Tapo Smart Platform] Loading accessory from cache: smart plug 2
[16/10/2024, 20:54:19] [Tapo Smart Platform] Loading accessory from cache: smart plug 3
[16/10/2024, 20:54:19] [Tapo Smart Platform] Executed didFinishLaunching callback
[16/10/2024, 20:54:19] [Tapo Smart Platform] Restoring existing accessory from cache: smart plug 1
[16/10/2024, 20:54:19] [Tapo Smart Platform] Start adding accessory: 192.168.1.88
[16/10/2024, 20:54:19] [Tapo Smart Platform] Constructing P100 on host: 192.168.1.88
[16/10/2024, 20:54:19] [Tapo Smart Platform] Handshake P100 on host: 192.168.1.88
[16/10/2024, 20:54:20] [Tapo Smart Platform] Received Handshake P100 on host response: 192.168.1.88
[16/10/2024, 20:54:20] [Tapo Smart Platform] Trying KLAP Auth
[16/10/2024, 20:54:20] [Tapo Smart Platform] Trying new habdshake
[16/10/2024, 20:54:20] [Tapo Smart Platform] Received request on host response: 192.168.1.88
[16/10/2024, 20:54:20] [Tapo Smart Platform] Handshake 1 cookie: "TP_SESSIONID=1AXXXXXXXXXXXXXXXXXXXXXXXXXXXXD5;TIMEOUT=86400"
[16/10/2024, 20:54:20] [Tapo Smart Platform] Handshake 1 successful
[16/10/2024, 20:54:20] [Tapo Smart Platform] Received request on host response: 192.168.1.88
[16/10/2024, 20:54:20] [Tapo Smart Platform] Handshake 2 successful:
[16/10/2024, 20:54:20] [Tapo Smart Platform] Init cipher successful
[16/10/2024, 20:54:20] [Tapo Smart Platform] decrypted: {"result":{"device_id":"802225984B5E56EB52C3A83C110C6FC4229892FD","fw_ver":"1.2.5 Build 240411 Rel.143808","hw_ver":"2.0","type":"SMART.TAPOPLUG","model":"P100","mac":"40-AE-30-FB-9C-B2","hw_id":"4012E37933F469A8790D690E12080BB6","fw_id":"00000000000000000000000000000000","oem_id":"525FC9C0545B4C8BEF51FA66130E51DE","ip":"192.168.1.88","time_diff":0,"ssid":"NTM=","rssi":-46,"signal_level":3,"auto_off_status":"off","auto_off_remain_time":0,"longitude":-10000,"latitude":550000,"lang":"en_US","avatar":"plug","region":"Europe/London","specs":"","nickname":"U2XXXXXXXXXXXXXX","has_set_location_info":true,"device_on":false,"on_time":0,"default_states":{"type":"last_states","state":{}},"overheated":false},"error_code":0}
[16/10/2024, 20:54:20] [Tapo Smart Platform] decrypted fixed: {"result":{"device_id":"802225984B5E56EB52C3A83C110C6FC4229892FD","fw_ver":"1.2.5 Build 240411 Rel.143808","hw_ver":"2.0","type":"SMART.TAPOPLUG","model":"P100","mac":"40-AE-30-FB-9C-B2","hw_id":"4012E37933F469A8790D690E12080BB6","fw_id":"00000000000000000000000000000000","oem_id":"525FC9C0545B4C8BEF51FA66130E51DE","ip":"192.168.1.88","time_diff":0,"ssid":"NTM=","rssi":-46,"signal_level":3,"auto_off_status":"off","auto_off_remain_time":0,"longitude":-10000,"latitude":550000,"lang":"en_US","avatar":"plug","region":"Europe/London","specs":"","nickname":"U2XXXXXXXXXXXXXX","has_set_location_info":true,"device_on":false,"on_time":0,"default_states":{"type":"last_states","state":{}},"overheated":false},"error_code":0}
[16/10/2024, 20:54:20] [Tapo Smart Platform] Device Info:  {
[16/10/2024, 20:54:20] [Tapo Smart Platform] interval: 9000
[16/10/2024, 20:54:21] [Tapo Smart Platform] Triggered GET OutletInUse
[16/10/2024, 20:54:21] [Tapo Smart Platform] Get Characteristic On -> false
[16/10/2024, 20:54:29] [Tapo Smart Platform] Updating state
[16/10/2024, 20:54:29] [Tapo Smart Platform] decrypted: {"result":{"device_id":"802225984B5E56EB52C3A83C110C6FC4229892FD","fw_ver":"1.2.5 Build 240411 Rel.143808","hw_ver":"2.0","type":"SMART.TAPOPLUG","model":"P100","mac":"40-AE-30-FB-9C-B2","hw_id":"4012E37933F469A8790D690E12080BB6","fw_id":"00000000000000000000000000000000","oem_id":"525FC9C0545B4C8BEF51FA66130E51DE","ip":"192.168.1.88","time_diff":0,"ssid":"NTM=","rssi":-47,"signal_level":3,"auto_off_status":"off","auto_off_remain_time":0,"longitude":-10000,"latitude":550000,"lang":"en_US","avatar":"plug","region":"Europe/London","specs":"","nickname":"U2XXXXXXXXXXXXXX","has_set_location_info":true,"device_on":false,"on_time":0,"default_states":{"type":"last_states","state":{}},"overheated":false},"error_code":0}
[16/10/2024, 20:54:29] [Tapo Smart Platform] decrypted fixed: {"result":{"device_id":"802225984B5E56EB52C3A83C110C6FC4229892FD","fw_ver":"1.2.5 Build 240411 Rel.143808","hw_ver":"2.0","type":"SMART.TAPOPLUG","model":"P100","mac":"40-AE-30-FB-9C-B2","hw_id":"4012E37933F469A8790D690E12080BB6","fw_id":"00000000000000000000000000000000","oem_id":"525FC9C0545B4C8BEF51FA66130E51DE","ip":"192.168.1.88","time_diff":0,"ssid":"NTM=","rssi":-47,"signal_level":3,"auto_off_status":"off","auto_off_remain_time":0,"longitude":-10000,"latitude":550000,"lang":"en_US","avatar":"plug","region":"Europe/London","specs":"","nickname":"U2XXXXXXXXXXXXXX","has_set_location_info":true,"device_on":false,"on_time":0,"default_states":{"type":"last_states","state":{}},"overheated":false},"error_code":0}
[16/10/2024, 20:54:29] [Tapo Smart Platform] Device Info:  {
  device_id: '802225984B5E56EB52C3A83C110C6FC4229892FD',
  fw_ver: '1.2.5 Build 240411 Rel.143808',
  hw_ver: '2.0',
  type: 'SMART.TAPOPLUG',
  model: 'P100',
  mac: '40-AE-30-FB-9C-B2',
  hw_id: '4012E37933F469A8790D690E12080BB6',
  fw_id: '00000000000000000000000000000000',
  oem_id: '525FC9C0545B4C8BEF51FA66130E51DE',
  ip: '192.168.1.88',
  time_diff: 0,
  ssid: 'NTM=',
  rssi: -47,
  signal_level: 3,
  auto_off_status: 'off',
  auto_off_remain_time: 0,
  longitude: -10000,
  latitude: 550000,
  lang: 'en_US',
  avatar: 'plug',
  region: 'Europe/London',
  specs: '',
  nickname: 'U2XXXXXXXXXXXXXX',
  has_set_location_info: true,
  device_on: false,
  on_time: 0,
  default_states: { type: 'last_states', state: {} },
  overheated: false,
  last_update: 1729108469413
}
[16/10/2024, 20:54:29] [Tapo Smart Platform] Get Characteristic On -> false
** at this point I powered on the plug manually **
[16/10/2024, 20:55:56] [Tapo Smart Platform] Triggered GET OutletInUse
[16/10/2024, 20:55:56] [Tapo Smart Platform] Get Characteristic On -> false
[16/10/2024, 20:59:18] [Tapo Smart Platform] Triggered GET OutletInUse
[16/10/2024, 20:59:18] [Tapo Smart Platform] Get Characteristic On -> false

Plugin Config:

{
    "bridge": {
        "name": "Homebridge 1CEC",
        "username": "0E:D9:46:0B:1C:EC",
        "port": 51390,
        "pin": "799-84-996",
        "advertiser": "avahi"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "auth": "form",
            "theme": "auto",
            "lightingMode": "auto",
            "temp": "/sys/class/thermal/thermal_zone0/temp",
            "tempUnits": "c",
            "lang": "auto",
            "platform": "config"
        },
        {
            "name": "Tapo Smart Platform",
            "username": "[email protected]",
            "password": "XXXXXX-XXXXXX-XXXXXX",
            "devices": [
                {
                    "name": "smart plug 1",
                    "host": "192.168.1.88",
                    "type": "Plug",
                    "updateInterval": 9,
                    "timeout": 2
                },
                {
                    "name": "smart plug 2",
                    "host": "192.168.1.89",
                    "type": "Plug",
                    "updateInterval": 12,
                    "timeout": 2
                },
                {
                    "name": "smart plug 3",
                    "host": "192.168.1.90",
                    "type": "Plug",
                    "updateInterval": 11,
                    "timeout": 2
                }
            ],
            "platform": "TapoP100"
        }
    ],
    "disabledPlugins": []
}

Screenshots:

Environment:

  • Plugin Version: v1.5.2-beta6 (but same behaviour with v1.5.1)
  • Homebridge Version: v1.8.4
  • Node.js Version: v20.18.0
  • NPM Version: 10.8.2
  • Operating System: Debian GNU/Linux Bookworm (12)
@PaulHaldane PaulHaldane added the bug Something isn't working label Oct 16, 2024
@PaulHaldane
Copy link
Author

Comparing the code for updateState in platformTPLinkAccessory.ts (which I think is the one used for P100 plugs and in platformL510EAccessory.ts I see that the 510 version has the following code at the end ...

    setTimeout(()=>{
      this.updateState(interval);
    }, interval);

which I reckon gets called when the request to the device succeeds. The P100 version doesn't seem to have the equivalent for the happy path which would explain why we get the plug's state at initialisation but never again.

@apatsufas apatsufas mentioned this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant