def zhaopenclose_message(websocket_message, rest_message): return { 'event': websocket_message['e'], 'state': failsafe(lambda : 'open' if websocket_message['state']['open'] else 'closed'), 'battery': failsafe(lambda : websocket_message['config']['battery']), 'temperature': failsafe(lambda : websocket_message['config']['temperature']), }
def zhaswitch_message(websocket_message, rest_message): button_map = { 1002: 'button1', 2002: 'button2', 3002: 'button3', 4002: 'button4', 5002: 'button5', } return { 'event': websocket_message['e'], 'button': failsafe(lambda : button_map[websocket_message['state']['buttonevent']]), 'battery': failsafe(lambda : websocket_message['config']['battery']), 'temperature': failsafe(lambda : websocket_message['config']['temperature']), }
def zhapress_message(websocket_message, rest_message): return { 'event': websocket_message['e'], 'pressure': failsafe(lambda : websocket_message['state']['pressure']), 'battery': failsafe(lambda : websocket_message['config']['battery']), }
def zhahumidity_message(websocket_message, rest_message): return { 'event': websocket_message['e'], 'humidity': failsafe(lambda : websocket_message['state']['humidity'] / 100), 'battery': failsafe(lambda : websocket_message['config']['battery']), }
def zhatemp_message(websocket_message, rest_message): return { 'event': websocket_message['e'], 'temperature': failsafe(lambda : websocket_message['state']['temperature'] / 100), 'battery': failsafe(lambda : websocket_message['config']['battery']), }