def toggle(): command = get_base_command() if store.get(STORE_KEY + 'off'): store.delete(STORE_KEY + 'off') rgb = store.get(STORE_KEY) or '99ffffff' command['data']['rgb'] = int(rgb, 16) else: store.set(STORE_KEY + 'off', 1) command['data']['rgb'] = 0 send_command(command)
def play(sound_id, volume=20): """ Play one of standard ringtones or user-defined sound. `sound_id` - 0-8, 10, 13, 20-29 - standard ringtones; >= 10001 - user-defined ringtones uploaded to your gateway via MiHome app `volume` - level from 1 to 100 Check the reference to get more about sound_id value: https://github.com/louisZL/lumi-gateway-local-api/blob/master/%E7%BD%91%E5%85%B3.md """ command = get_base_command() command['data'].update(mid=sound_id, vol=volume) send_command(command)
def set_rgb(rgb, send=True): brightness, color = rgb[:2], rgb[2:] if int(brightness, 16) > 100: brightness = '64' rgb = brightness + color store.set(STORE_KEY, rgb) if not send or is_blocked(): return store.delete(STORE_KEY + 'off') command = get_base_command() command['data']['rgb'] = int(rgb, 16) send_command(command)
def stop(): """Stop playing any sound from speaker""" command = get_base_command() command['data'].update(mid=10000) send_command(command)