comparison service/rdf_to_mqtt/rdf_to_mqtt.py @ 776:8fa420250799

add headboard
author drewp@bigasterisk.com
date Sun, 28 Jun 2020 14:30:52 -0700
parents 82bea37aeb92
children df7035db28f1
comparison
equal deleted inserted replaced
775:2a3e791baff7 776:8fa420250799
54 }, 54 },
55 ROOM['theater']: { 55 ROOM['theater']: {
56 'root': 'theater_blaster/ir_out', 56 'root': 'theater_blaster/ir_out',
57 'values': 'theaterOutputs', 57 'values': 'theaterOutputs',
58 }, 58 },
59 ROOM['bedHeadboard']: {
60 'root': 'bed/light/headboard/command',
61 },
59 #-t theater_blaster/ir_out -m 'input_game' 62 #-t theater_blaster/ir_out -m 'input_game'
60 #-t theater_blaster/ir_out -m 'input_bd' 63 #-t theater_blaster/ir_out -m 'input_bd'
61 #-t theater_blaster/ir_out -m 'input_cbl' 64 #-t theater_blaster/ir_out -m 'input_cbl'
62 #-t theater_blaster/ir_out -m 'input_pc' 65 #-t theater_blaster/ir_out -m 'input_pc'
63 #-t theater_blaster/ir_out/volume_up -m '{"times":1}' 66 #-t theater_blaster/ir_out/volume_up -m '{"times":1}'
98 delta = int(stmt[2].toPython()) 101 delta = int(stmt[2].toPython())
99 which = 'up' if delta > 0 else 'down' 102 which = 'up' if delta > 0 else 'down'
100 self._publish(topic=f'theater_blaster/ir_out/volume_{which}', 103 self._publish(topic=f'theater_blaster/ir_out/volume_{which}',
101 message=json.dumps({'timed': abs(delta)})) 104 message=json.dumps({'timed': abs(delta)}))
102 ignored = False 105 ignored = False
106 if stmt[0:2] == (dev, ROOM['color']):
107 h = stmt[2].toPython()
108 r,g,b = int(h[1:3], 16), int(h[3:5], 16), int(h[5:7], 16)
109 self._publish(topic=attrs['root'],
110 message=json.dumps({'state': 'ON' if r or g or b else 'OFF',
111 'color': {'r': r, 'g': g, 'b': b},
112 'white_value': max(r, g, b)}))
113 ignored = false
103 if ignored: 114 if ignored:
104 log.warn("ignoring %s", stmt) 115 log.warn("ignoring %s", stmt)
105 116
106 def _publishOnOff(self, attrs, brightness): 117 def _publishOnOff(self, attrs, brightness):
107 msg = 'OFF' 118 msg = 'OFF'