def __init__(self, serial): self.id = [0xFF, 0xFF, 0xFF, 0xFF] self.senderId = [0x00, 0x00, 0x00, 0x00] self.action = [0x10] self.serial = serial self.tel = BaseTelegram() self.tel.setType(BaseTelegram.RADIO)
class Rcm250: """ This class permit to use a rcm250. Learning: - Pull LRN button on Rcm250 - Set the sender id you want with setSenderId method - Use the switchOn method. """ def __init__(self, serial): self.id = [0xFF, 0xFF, 0xFF, 0xFF] self.senderId = [0x00, 0x00, 0x00, 0x00] self.action = [0x10] self.serial = serial self.tel = BaseTelegram() self.tel.setType(BaseTelegram.RADIO) def setId(self, id): self.id = id def setSenderId(self, id): self.senderId = id def switchOn(self): data = [0xF6, 0x10] + self.senderId + [0x30] self.tel.setData(data) opData = [0x01] + self.id + [0x2D, 0x00] self.tel.setOptionalData(opData) self.serial.write(self.tel.toByte()) def switchOff(self): data = [0xF6, 0x30] + self.senderId + [0x30] self.tel.setData(data) opData = [0x01] + self.id + [0x2D, 0x00] self.tel.setOptionalData(opData) self.serial.write(self.tel.toByte())
from enOcean.telegram.BaseTelegram import BaseTelegram # Construction d un telegram de base (Allumer) base = BaseTelegram() base.setType(BaseTelegram.RADIO) base.setData([0xF6, 0x10, 0x00, 0x00, 0x00, 0x00, 0x30]) base.setOptionalData([0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x2D, 0x00]) print base.toString() print '\n' print base.fromBytes(base.toByte()) print base.toString()
from enOcean.telegram.BaseTelegram import BaseTelegram # Construction d un telegram de base (Allumer) base = BaseTelegram() base.setType(BaseTelegram.RADIO) base.setData([0xF6, 0x10, 0x00, 0x00, 0x00, 0x00, 0x30 ]) base.setOptionalData([0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x2D, 0x00]) print base.toString() print '\n' print base.fromBytes(base.toByte()) print base.toString()
from time import sleep from enOcean.Modules.Rcm250 import Rcm250 from enOcean.telegram.BaseTelegram import BaseTelegram import serial ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=1) # Construction d un telegram de base (Allumer) base = BaseTelegram() base.setType(BaseTelegram.COMMON_COMMAND) base.setData([0x07, 0xFF, 0xFF, 0x77, 0x01]) #base.setOptionalData([0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x2D, 0x00]) # Envoi #ser.write(base.toByte()) # Reception #base.fromBytes(ser.read(100)) #Raise BadCrcException ou BadDataLengthException si le packet est mal forme # Rcm 250 rcm = Rcm250(ser) rcm.setId([0xFF, 0xFF, 0xff, 0xff]) rcm.setSenderId([0xFF, 0xFF, 0x77, 0x01]) rcm.switchOn() sleep(3) rcm.switchOff()