def click_handler(channel, click_type, was_queued, time_diff):
log.info(channel.bd_addr + " " + str(click_type))
if str(click_type) == 'ClickType.ButtonSingleClick':
try:
log.info("Switching on lights associated with button " + channel.bd_addr)
for light in groups[channel.bd_addr]['group']:
bridge.get(light).on()
except KeyError:
log.warning("Light not found for button " + str(channel.bd_addr))
elif str(click_type) == 'ClickType.ButtonHold':
# turn off all lights
log.info("Turning off all lights...")
for light in bridge:
light.off()
return
评论列表
文章目录