def shutter_status(master_version): """ Read the status of a shutter module. """ if master_version >= (3, 143, 78): return MasterCommandSpec("SO", [Field.byte("module_nr"), Field.padding(12)], [Field.byte("module_nr"), Field.padding(3), Field.byte("status"), Field.byte("shutter_lock"), Field.lit('\r\n')]) return MasterCommandSpec("SO", [Field.byte("module_nr"), Field.padding(12)], [Field.byte("module_nr"), Field.padding(3), Field.byte("status"), Field.lit('\r\n')])
def input_list(master_version): """ The message sent by the master whenever an input changes. """ if master_version < (3, 143, 88): return MasterCommandSpec("IL", [], [Field.byte('input'), Field.byte('output'), Field.lit("\r\n")]) return MasterCommandSpec("IL", [], [Field.byte('input'), Field.byte('output'), Field.byte('status'), Field.lit("\r\n")])
def module_discover_start(): """ Put the master in module discovery mode. """ return MasterCommandSpec( "DA", [Field.padding(13)], [Field.str("resp", 2), Field.padding(11), Field.lit("\r\n")])
def clear_error_list(): """ Clear the number of errors. """ return MasterCommandSpec( "ec", [Field.padding(13)], [Field.str("resp", 2), Field.padding(11), Field.lit("\r\n")])
def error_list(): """ Get the number of errors for each input and output module. """ return MasterCommandSpec("el", [Field.padding(13)], [ Field("errors", ErrorListFieldType()), Field.crc(), Field.lit("\r\n") ])
def pulse_list(): """ List the pulse counter values. """ return MasterCommandSpec("PL", [Field.padding(13)], [ Field.int('pv0'), Field.int('pv1'), Field.int('pv2'), Field.int('pv3'), Field.int('pv4'), Field.int('pv5'), Field.int('pv6'), Field.int('pv7'), Field.int('pv8'), Field.int('pv9'), Field.int('pv10'), Field.int('pv11'), Field.int('pv12'), Field.int('pv13'), Field.int('pv14'), Field.int('pv15'), Field.int('pv16'), Field.int('pv17'), Field.int('pv18'), Field.int('pv19'), Field.int('pv20'), Field.int('pv21'), Field.int('pv22'), Field.int('pv23'), Field.crc(), Field.lit('\r\n') ])
def thermostat_mode(): """ Read the current thermostat mode """ return MasterCommandSpec( "TM", [Field.padding(13)], [Field.byte('mode'), Field.padding(12), Field.lit('\r\n')])
def eeprom_list(): """ List all bytes from a certain eeprom bank """ return MasterCommandSpec( "EL", [Field.byte("bank"), Field.padding(12)], [Field.byte("bank"), Field.str("data", 256), Field.lit("\r\n")])
def reset(): """ Reset the gateway, used for firmware updates. """ return MasterCommandSpec( "re", [Field.padding(13)], [Field.str("resp", 2), Field.padding(11), Field.lit("\r\n")])
def add_virtual_module(): """ Adds a virtual module """ return MasterCommandSpec( "AV", [Field.str('vmt', 1), Field.padding(12)], [Field.str("resp", 2), Field.padding(11), Field.lit('\r\n')])
def get_module_version(): """ Get the version of the module. """ return MasterCommandSpec("FV", [Field.str('addr', 4), Field.crc(), Field.padding(6)], [Field.str('addr', 4), Field.byte("error_code"), Field.byte("hw_version"), Field.byte("f1"), Field.byte("f2"), Field.byte("f3"), Field.byte("status"), Field.crc(), Field.lit("\r\n")])
def module_discover_stop(): """ Put the master into the normal working state. """ return MasterCommandSpec( "DO", [Field.padding(13)], [Field.str("resp", 2), Field.padding(11), Field.lit("\r\n")])
def input_list(): """ The message sent by the master whenever an input is enabled. """ return MasterCommandSpec( "IL", [], [Field.byte('input'), Field.byte('output'), Field.lit("\r\n")])
def modules_goto_application(): """ Let the module go to application. """ return MasterCommandSpec("FG", [Field.str('addr', 4), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(6)], [Field.str('addr', 4), Field.byte("error_code"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(5), Field.lit("\r\n")])
def modules_update_firmware_block(): """ Upload 1 block of 64 bytes to the module. """ return MasterCommandSpec("FD", [Field.str('addr', 4), Field.int("block"), Field.str("bytes", 64), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1')], [Field.str('addr', 4), Field.byte("error_code"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.lit("\r\n")])
def modules_integrity_check(): """ Check the integrity of the new code. """ return MasterCommandSpec("FE", [Field.str('addr', 4), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(6)], [Field.str('addr', 4), Field.byte("error_code"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(5), Field.lit("\r\n")])
def modules_new_firmware_version(): """ Preprare the slave module for a new version. """ return MasterCommandSpec("FN", [Field.str('addr', 4), Field.byte("f1n"), Field.byte("f2n"), Field.byte("f3n"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(3)], [Field.str('addr', 4), Field.byte("error_code"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(5), Field.lit("\r\n")])
def set_virtual_sensor(): """ Set the values (temperature, humidity, brightness) of a virtual sensor. """ return MasterCommandSpec("VS", [Field.byte('sensor'), Field.svt('tmp'), Field.svt('hum'), Field.svt('bri'), Field.padding(9)], [Field.byte('sensor'), Field.svt('tmp'), Field.svt('hum'), Field.svt('bri'), Field.padding(9), Field.lit('\r\n')])
def modules_goto_bootloader(): """ Reset the module to go to the bootloader. """ return MasterCommandSpec("FR", [Field.str('addr', 4), Field.byte('sec'), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(5)], [Field.str('addr', 4), Field.byte("error_code"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(5), Field.lit("\r\n")])
def event_triggered(): """ The message sent by the master to trigger an event. This event is triggered by basic action 60. """ return MasterCommandSpec( "EV", [], [Field.byte('code'), Field.padding(12), Field.lit('\r\n')])
def read_setpoint(): """ Read the programmed setpoint of a thermostat """ return MasterCommandSpec("rs", [Field.byte('thermostat'), Field.padding(12)], [Field.byte('thermostat'), Field.svt('act'), Field.svt('csetp'), Field.svt('psetp0'), Field.svt('psetp1'), Field.svt('psetp2'), Field.svt('psetp3'), Field.svt('psetp4'), Field.svt('psetp5'), Field.byte('sensor_nr'), Field.byte('output0_nr'), Field.byte('output1_nr'), Field.byte('output0'), Field.byte('output1'), Field.svt('outside'), Field.byte('mode'), Field.str('name', 16), Field.byte('pid_p'), Field.byte('pid_i'), Field.byte('pid_d'), Field.byte('pid_ithresh'), Field.svt('threshold_temp'), Field.byte('days'), Field.byte('hours'), Field.byte('minutes'), Field.svt('mon_start_d1'), Field.svt('mon_stop_d1'), Field.svt('mon_start_d2'), Field.svt('mon_stop_d2'), Field.svt('tue_start_d1'), Field.svt('tue_stop_d1'), Field.svt('tue_start_d2'), Field.svt('tue_stop_d2'), Field.svt('wed_start_d1'), Field.svt('wed_stop_d1'), Field.svt('wed_start_d2'), Field.svt('wed_stop_d2'), Field.svt('thu_start_d1'), Field.svt('thu_stop_d1'), Field.svt('thu_start_d2'), Field.svt('thu_stop_d2'), Field.svt('fri_start_d1'), Field.svt('fri_stop_d1'), Field.svt('fri_start_d2'), Field.svt('fri_stop_d2'), Field.svt('sat_start_d1'), Field.svt('sat_stop_d1'), Field.svt('sat_start_d2'), Field.svt('sat_stop_d2'), Field.svt('sun_start_d1'), Field.svt('sun_stop_d1'), Field.svt('sun_start_d2'), Field.svt('sun_stop_d2'), Field.lit('T'), Field.svt('mon_temp_d1'), Field.svt('tue_temp_d1'), Field.svt('wed_temp_d1'), Field.svt('thu_temp_d1'), Field.svt('fri_temp_d1'), Field.svt('sat_temp_d1'), Field.svt('sun_temp_d1'), Field.svt('mon_temp_d2'), Field.svt('tue_temp_d2'), Field.svt('wed_temp_d2'), Field.svt('thu_temp_d2'), Field.svt('fri_temp_d2'), Field.svt('sat_temp_d2'), Field.svt('sun_temp_d2'), Field.svt('mon_temp_n'), Field.svt('tue_temp_n'), Field.svt('wed_temp_n'), Field.svt('thu_temp_n'), Field.svt('fri_temp_n'), Field.svt('sat_temp_n'), Field.svt('sun_temp_n'), Field.crc(), Field.lit('\r\n')])
def read_input_module(master_version): """ Read the status about all inputs of an input module """ if master_version < (3, 143, 88): raise NotImplementedError("read_input_module() not supported on master version {}".format(master_version)) return MasterCommandSpec("RI", [Field.byte("input_module_nr"), Field.padding(12)], [Field.byte('input_module_nr'), Field.byte('input_status'), Field.padding(8), Field.crc(), Field.lit('\r\n')])
def modules_new_crc(): """ Write the new crc code to the bootloaded module. """ return MasterCommandSpec("FC", [Field.str('addr', 4), Field.byte("ccrc0"), Field.byte("ccrc1"), Field.byte("ccrc2"), Field.byte("ccrc3"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(2)], [Field.str('addr', 4), Field.byte("error_code"), Field.lit('C'), Field.byte('crc0'), Field.byte('crc1'), Field.padding(5), Field.lit("\r\n")])
def setpoint_list(): """ Read the current setpoint of the thermostats in series of 12 """ return MasterCommandSpec("SL", [Field.byte("series"), Field.padding(12)], [Field.byte("series"), Field.svt('tmp0'), Field.svt('tmp1'), Field.svt('tmp2'), Field.svt('tmp3'), Field.svt('tmp4'), Field.svt('tmp5'), Field.svt('tmp6'), Field.svt('tmp7'), Field.svt('tmp8'), Field.svt('tmp9'), Field.svt('tmp10'), Field.svt('tmp11'), Field.lit('\r\n')])
def temperature_list(): """ Read the temperature thermostat sensor list for a series of 12 sensors """ return MasterCommandSpec("TL", [Field.byte("series"), Field.padding(12)], [Field.byte("series"), Field.svt('tmp0'), Field.svt('tmp1'), Field.svt('tmp2'), Field.svt('tmp3'), Field.svt('tmp4'), Field.svt('tmp5'), Field.svt('tmp6'), Field.svt('tmp7'), Field.svt('tmp8'), Field.svt('tmp9'), Field.svt('tmp10'), Field.svt('tmp11'), Field.lit('\r\n')])
def set_time(): """ Set the time on the master. """ return MasterCommandSpec("st", [Field.byte('sec'), Field.byte('min'), Field.byte('hours'), Field.byte('weekday'), Field.byte('day'), Field.byte('month'), Field.byte('year'), Field.padding(6)], [Field.byte('sec'), Field.byte('min'), Field.byte('hours'), Field.byte('weekday'), Field.byte('day'), Field.byte('month'), Field.byte('year'), Field.padding(6), Field.lit("\r\n")])
def status(): """ Get the status of the master. """ return MasterCommandSpec("ST", [Field.padding(13)], [Field.byte('seconds'), Field.byte('minutes'), Field.byte('hours'), Field.byte('weekday'), Field.byte('day'), Field.byte('month'), Field.byte('year'), Field.lit('\x00'), Field.byte('mode'), Field.byte('f1'), Field.byte('f2'), Field.byte('f3'), Field.byte('h'), Field.lit('\r\n')])
def read_output(): """ Read the information about an output """ return MasterCommandSpec("ro", [Field.byte("id"), Field.padding(12)], [Field.byte('id'), Field.str('type', 1), Field.byte('light'), Field.int('timer'), Field.int('ctimer'), Field.byte('status'), Field.dimmer('dimmer'), Field.byte('controller_out'), Field.byte('max_power'), Field.byte('floor_level'), Field.bytes('menu_position', 3), Field.str('name', 16), Field.crc(), Field.lit('\r\n')])
def number_of_io_modules(): """ Read the number of input and output modules """ return MasterCommandSpec("rn", [Field.padding(13)], [ Field.byte("in"), Field.byte("out"), Field.byte("shutter"), Field.padding(10), Field.lit('\r\n') ])
def indicate(): """ Flash the led for a given output/input/sensor. """ return MasterCommandSpec( "IN", [Field.byte('type'), Field.byte('id'), Field.padding(11)], [Field.str("resp", 2), Field.padding(11), Field.lit("\r\n")])