OOK(legacy) and FSK(MiHome) working in same combined.py build
1 parent 38dce93 commit 602b59c488dc720879d60fcab1e7afe7f5ac2d5b
@David Whale David Whale authored on 15 May 2016
Showing 1 changed file
View
28
src/combined.py
# issues to be implemented and tested on top of the raw radio interface, as these
# will be much nicer to use.
 
import time
from energenie import Messages, OpenThings, radio, encoder
from energenie import Messages, OpenThings, radio, encoder, Devices
 
# build FSK messages for MiHome purple
 
OpenThings.init(Devices.CRYPT_PID)
 
PURPLE_ID = 0x68B # captured from a real device using Monitor.py
m = OpenThings.alterMessage(
Messages.SWITCH,
GREEN_OFF = encoder.build_switch_msg(False, device_address=1)
 
 
def switch_loop():
print("Turning both ON")
radio.transmitter(ook=True)
print("Turning green ON")
radio.modulation(ook=True)
radio.transmit(GREEN_ON)
radio.transmitter(fsk=True)
time.sleep(0.5)
 
print("Turning purple ON")
radio.modulation(fsk=True)
radio.transmit(purple_on)
time.sleep(2)
 
print("Turning both OFF")
radio.transmitter(ook=True)
print("Turning green OFF")
radio.modulation(ook=True)
radio.transmit(GREEN_OFF)
radio.transmitter(fsk=True)
time.sleep(0.5)
 
print("Turning purple OFF")
radio.modulation(fsk=True)
radio.transmit(purple_off)
time.sleep(2)