shauntarves/wyze-sdk

Bulbs are only ever returning is_on == False

stancubed opened this issue · 5 comments

I've written a function to iterate through a list of bulbs and get their is_on status, but no matter the state of the bulbs, it's returning False.
Snippet:

api_response = client.bulbs.list()
    for bulb in api_response:
        if "Lab" in bulb.nickname:
            print(f"{bulb.nickname} ({bulb.product.model}) is set to status {bulb.is_on}")

Output:

Lab 2 (WLPA19C) is set to status False
Lab 5 (WLPA19C) is set to status False
Lab 4 (WLPA19C) is set to status False
Lab 3 (WLPA19C) is set to status False
Lab 6 (WLPA19C) is set to status False
Lab 7 (WLPA19C) is set to status False
Lab 8 (WLPA19C) is set to status False
Lab 1 (WLPA19C) is set to status False

Am I missing a step here or expecting something different from the intention?

Thanks for any help!

@stancubed @robughblah ,

This one is a bit of a head-scratcher for me. The OLD bulb (first version, not color) used a device parameter called switch_state to report whether it was on/off. Newer bulbs, particularly the mesh color, had switched to the standard prop-based approach and used the P3 prop. It looks like at some point, that changed, but I can't figure out when/where. Maybe they standardized bulb logic/properties across all the models?

Anyway, please check out https://github.com/shauntarves/wyze-sdk/tree/126-bulbs-are-only-ever-returning-is_on-%3D%3D-false and see if this resolves your issue. I only have a color bulb, and I would really like to regression test this against the second-gen white bulb and the light strips. @anthonystabile would you be able to try this version against your light strips to see if bulb.is_on reports correctly?

@JohnMTorgerson @JRGould - could use your help on this one too if you have bulbs you can try

I'm seeing the bulb power state coming back in the P3 prop on my HL_HWB2 bulbs - so if I change switch_state on this line:

return PropDef("switch_state", bool, int)

to P3, then bulb.is_on will accurately report the power state of the bulb.

here are the raw JSON responses for that bulb when it's on / off

# bulb on
{'ts': 1675802934728, 'code': '1', 'msg': '', 'data': {'property_list': [
      {'pid': 'P1', 'value': '1', 'ts': 0
      },
      {'pid': 'P1501', 'value': '1', 'ts': 1675751437426
      },
      {'pid': 'P1502', 'value': '2700', 'ts': 1671755346238
      },
      {'pid': 'P1503', 'value': '', 'ts': 0
      },
      {'pid': 'P1504', 'value': '-60', 'ts': 1675800512033
      },
      {'pid': 'P1505', 'value': '0', 'ts': 0
      },
      {'pid': 'P1506', 'value': '0', 'ts': 1664483890034
      },
      {'pid': 'P1509', 'value': '0', 'ts': 1664483890034
      },
      {'pid': 'P1511', 'value': '6918ab128e15486d', 'ts': 1664483906949
      },
      {'pid': 'P1513', 'value': '0', 'ts': 0
      },
      {'pid': 'P1514', 'value': '0', 'ts': 0
      },
      {'pid': 'P1527', 'value': '', 'ts': 0
      },
      {'pid': 'P1528', 'value': '0', 'ts': 1671755346238
      },
      {'pid': 'P1529', 'value': '1', 'ts': 1664483890034
      },
      {'pid': 'P1530', 'value': '1', 'ts': 1664483890079
      },
      {'pid': 'P1531', 'value': '1', 'ts': 1664483890079
      },
      {'pid': 'P3', 'value': '1', 'ts': 1675800512033
      },
      {'pid': 'P5', 'value': '1', 'ts': 1675303966709
      },
      {'pid': 'P7', 'value': '0', 'ts': 0
      }
    ]
  }
}

# bulb off
{'ts': 1675803097248, 'code': '1', 'msg': '', 'data': {'property_list': [
      {'pid': 'P1', 'value': '1', 'ts': 0
      },
      {'pid': 'P1501', 'value': '1', 'ts': 1675751437426
      },
      {'pid': 'P1502', 'value': '2700', 'ts': 1671755346238
      },
      {'pid': 'P1503', 'value': '', 'ts': 0
      },
      {'pid': 'P1504', 'value': '-60', 'ts': 1675800512033
      },
      {'pid': 'P1505', 'value': '0', 'ts': 0
      },
      {'pid': 'P1506', 'value': '0', 'ts': 1664483890034
      },
      {'pid': 'P1509', 'value': '0', 'ts': 1664483890034
      },
      {'pid': 'P1511', 'value': '6918ab128e15486d', 'ts': 1664483906949
      },
      {'pid': 'P1513', 'value': '0', 'ts': 0
      },
      {'pid': 'P1514', 'value': '0', 'ts': 0
      },
      {'pid': 'P1527', 'value': '', 'ts': 0
      },
      {'pid': 'P1528', 'value': '0', 'ts': 1671755346238
      },
      {'pid': 'P1529', 'value': '1', 'ts': 1664483890034
      },
      {'pid': 'P1530', 'value': '1', 'ts': 1664483890079
      },
      {'pid': 'P1531', 'value': '1', 'ts': 1664483890079
      },
      {'pid': 'P3', 'value': '0', 'ts': 1675803088534
      },
      {'pid': 'P5', 'value': '1', 'ts': 1675303966709
      },
      {'pid': 'P7', 'value': '0', 'ts': 0
      }
    ]
  }
}

Yeah, that's what I was assuming we'd see. I need some confirmation on the other bulb types though so I can put in more specialized logic.