photons
photons copied to clipboard
Issue Getting Data From Mini Style Bulbs
I have a variety of LIFX devices in my home and am trying to log the wifi signal strength from them over time. I have found that all the DeviceMessages that I send to mini style bulbs (color or dd) always time out. My code has no issue getting responses from the BR30 style bulbs or the LIFX Z controllers. Is there anything special that I need to configure in order to receive messages from these devices? They are online and responding to UDP requests from my Loxone miniserver. Here is a snippet of the code that I was using to test receiving the messages back.
async def my_getpower(target, object):
reference = HardCodedSerials(object)
async with target.session() as sender:
try:
get_power = DeviceMessages.GetWifiInfo()
get_label = DeviceMessages.GetLabel()
async for pkt in sender([get_power, get_label], reference):
if pkt | DeviceMessages.StateWifiInfo:
print(f"Device {pkt.serial} has power level of {pkt.signal}")
elif pkt | DeviceMessages.StateLabel:
print(f"Device {pkt.serial} has a label of {pkt.label}")
except:
print(f"No Response from {object}")
I'm unsure why the minis would ignore that packet. I'd suggest contacting their support team and seeing if they can ask an engineer for you.
Though I will say the signal strength information is largely useless.
also, a couple notes on your code sample,
you likely want something more like
async def getpower(target, reference):
def error_catcher(error):
print(
f"Failed to get information from a device: {type(error).__name__}: {error}"
)
async with target.session() as sender:
msgs = [DeviceMessages.GetWifiInfo(), DeviceMessages.GetLabel()]
async for pkt in sender(msgs, reference, error_catcher=error_catcher):
if pkt | DeviceMessages.StateWifiInfo:
print(f"Device {pkt.serial} has power level of {pkt.signal}")
elif pkt | DeviceMessages.StateLabel:
print(f"Device {pkt.serial} has a label of {pkt.label}")
which logs something like
12:52:16 ERROR photons_transport.comms Didn't find some devices missing=['d073d5443322']
Failed to get information from a device: FailedToFindDevice: "Couldn't find a device" serial=d073d5443322
Failed to get information from a device: FailedToFindDevice: "Couldn't find a device" serial=d073d5443322
(HardCodedSerials caches the ip addresses of the serials it's aware of but if you're not using outside of one sender object and you already have a string or a list of strings, then you might as well just pass those into the sender directly as that has it's own cache anyways)
Thanks for the tips on how to better implement the code. I'm fairly new into python so my original snippet was probably quite sloppy. The reason I am grab the wifi signal strength is so that I can log it over time with influxdb and test out some different wifi configs with my unifi setup. I have some rogue bulbs that play nice one day but then go unresponsive for days at a time. So I am moving my unifi access points around and playing with some of the settings to see if I can get a more reliable setup. I will see if the engineers at Lifx can offer any insight, but given that this is third party to them I thought I'd ask here first.
Yeah, reasonable. I'm unsure if the data those packets return will be useful in either case, but I could be wrong
Note that Home Assistant has an RSSI sensor (which is disabled by default) for LIFX bulbs. I have it enabled across my entire fleet that contains ~40 Mini Color bulbs and they all respond fine. Also using UniFi networking, so I understand your frustration dialling this in.
My advice is to create an SSID specifically for your LIFX bulbs with everything except DTIM period and minimum data rate disabled. Here is my config which has been pretty stable for about a year now:
And here's a graph of RSSI for my office ceiling light for the last 24 hours:
The dip is when I reconfigured a different SSID and the UAP-AC-IW that's in my office restarted so the bulb reconnected to another AP for a while.