def __init__(self, isy_device=None, homie_settings=None, mqtt_settings=None): Base.__init__(self, isy_device) Device_Base.__init__( self, "isycontroller", "ISY Controller", homie_settings, mqtt_settings ) node = Node_Base(self, "status", "Status", "status") self.add_node(node) self.heartbeat = Property_String(node, "heartbeat", "Heart Beat") node.add_property(self.heartbeat) self.state_busy = Property_String(node, "state", "State") node.add_property(self.state_busy) self.http_connected = Property_String(node, "http", "HTTP Status") node.add_property(self.http_connected) self.websocket_connected = Property_String( node, "websocket", "Websocket Status" ) node.add_property(self.websocket_connected) self.add_communication_error_property() Device_Base.start(self)
def __init__(self, isy_device=None, homie_settings=None, mqtt_settings=None): Base.__init__(self, isy_device) Device_Base.__init__( self, self.get_homie_device_id(), isy_device.name, homie_settings, mqtt_settings, ) paddle_node = Node_Base(self, id="paddle", name="paddle", type_="paddle") self.add_node(paddle_node) self.paddle = Property_String(paddle_node, "paddle-action", "Paddle Action") paddle_node.add_property(self.paddle) Device_Base.start(self)
def add_communication_error_property(self): comms_node = Node_Base(self, id="communications", name="Communication", type_="status") self.add_node(comms_node) self.comm_ok_state = Property_Boolean(comms_node, "commsok", "Communication Ok", settable=False, value=True) self.comm_err_count = Property_Integer(comms_node, "commerrors", "Communication Errors", settable=False, value=0) self.comm_state_err_count = Property_Integer( comms_node, "commstateerrors", "Communication State Errors", settable=False, value=0) self.comm_requests = Property_Integer(comms_node, "commrequests", "Communication Requests", settable=False, value=0) comms_node.add_property(self.comm_ok_state) comms_node.add_property(self.comm_err_count) comms_node.add_property(self.comm_state_err_count) comms_node.add_property(self.comm_requests) self.publish_nodes(self.retained, self.qos)
def __init__(self, isy_device=None, homie_settings=None, mqtt_settings=None): Base.__init__(self, isy_device) Device_Base.__init__(self, 'isycontroller', 'ISY Controller', homie_settings, mqtt_settings) node = Node_Base(self, 'status', 'Status', 'status') self.add_node(node) self.heartbeat = Property_String(node, 'heartbeat', 'Heart Beat') node.add_property(self.heartbeat) self.state_busy = Property_String(node, 'state', 'State') node.add_property(self.state_busy) self.htpp_connected = Property_String(node, 'http', 'HTTP Status') node.add_property(self.htpp_connected) self.websocket_connected = Property_String(node, 'websocket', 'Websocket Status') node.add_property(self.websocket_connected) Device_Base.start(self)
def __init__( self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, device_comfoairq=None, connect_at_start=True, ): assert device_id assert name assert device_comfoairq assert mqtt_settings super().__init__ (device_id, name, homie_settings, mqtt_settings) self.device_comfoairq=device_comfoairq # Gateway Controls node = Node_Base(self,'controls','ComfoAirQ Gateway Controls','controls') self.add_node (node) node.add_property(Property_Switch(node,id='stayconnected',name = 'Stay connected to Comfoconnect' ,settable = True, set_value=self.set_stay_connected)) node.add_property(Property_Switch(node,id='reload',name = 'Publish Homie Devices' ,settable = True, set_value=self.set_reload)) node = Node_Base(self,'sensors','ComfoAirQ Gateway Sensors','sensors') self.add_node (node) node.add_property (Property_Enum (node,id='state',name = 'Connection state',settable = False,data_format=','.join(DEVICE_STATES))) if self.device_comfoairq is not None: self.device_comfoairq.comfoairq.add_on_state_change_callback(self.publish_connection_status) global repeating_timer if repeating_timer == None: repeating_timer = Repeating_Timer( self.homie_settings["update_interval"] ) repeating_timer.add_callback(self.publish_connection_status) self.start() if connect_at_start: self.set_stay_connected("ON") self.publish_connection_status()
def __init__(self, device_id=None, name=None, homie_settings=None, mqtt_settings=None): super().__init__(device_id, name, homie_settings, mqtt_settings) node = (Node_Base(self, 'status', 'Status', 'status')) self.add_node(node) self.account_status = Property_String(node, id='connectionstatus', name='Connection Status', value='Not Connected') node.add_property(self.account_status) self.last_update = Property_String(node, id='lastupdate', name='Last Update', value='None') node.add_property(self.last_update) self.device_count = Property_String(node, id='devicecount', name='Device Count', value='None') node.add_property(self.device_count) self.start()
def __init__(self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, speeds='OFF,LOW,MEDIUM,HIGH'): super().__init__(device_id, name, homie_settings, mqtt_settings) node = Node_Base(self, id='speed', name='Speed', type_='speed') self.add_node(node) self.speed_property = Property_Speed(node, data_format=speeds, set_value=self.set_speed) node.add_property(self.speed_property) self.start()
def __init__( self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, ): super().__init__(device_id, name, homie_settings, mqtt_settings) node = Node_Base(self, "button", "Button", "button") self.add_node(node) self.button = Property_Button( node, id="button", name="Button", ) node.add_property(self.button) self.start()
def __init__(self, isy_device=None, homie_settings=None, mqtt_settings=None): Base.__init__(self, isy_device) Device_Base.__init__(self, self.get_homie_device_id(), isy_device.name, homie_settings, mqtt_settings) paddle_node = Node_Base(self, id='paddle', name='paddle', type_='paddle') self.add_node(paddle_node) self.paddle = Property_String(paddle_node, 'paddle-action', 'Paddle Action') paddle_node.add_property(self.paddle) Device_Base.start(self)
def __init__(self, isy_device=None, homie_settings=None, mqtt_settings=None): Base.__init__(self, isy_device) Device_Base.__init__( self, self.get_homie_device_id(), isy_device.name, homie_settings, mqtt_settings, ) node = Node_Base(self, "program", "Program", "program") self.add_node(node) self.status = Property_String(node, "status", "Status") node.add_property(self.status) self.run = Property_Enum( node, id="run", name="Run Program", data_format="RUNIF,RUNTHEN,RUNELSE,STOP", set_value=self.set_run_program, ) node.add_property(self.run) self.start()
def __init__(self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, set_lift_mode=None): super().__init__(device_id, name, homie_settings, mqtt_settings) node = (Node_Base(self, 'boatlift', 'Boat Lift', 'boatlift')) self.add_node(node) self.set_lift_mode = Property_Enum( node, id='setliftmode', name='Set Lift Mode', data_format=','.join(LIFT_MODES), set_value=lambda value: set_lift_mode(value)) node.add_property(self.set_lift_mode) self.lift_mode = Property_String(node, id='liftmode', name='Lift Mode') node.add_property(self.lift_mode) self.lift_position = Property_String(node, id='position', name='Position') node.add_property(self.lift_position) self.lift_height = Property_String(node, id='height', name='Height') node.add_property(self.lift_height) self.lift_roll = Property_String(node, id='roll', name='Roll') node.add_property(self.lift_roll) self.lift_pitch = Property_String(node, id='pitch', name='Pitch') node.add_property(self.lift_pitch) self.valves = Property_String(node, id='valves', name='Valves') node.add_property(self.valves) self.water_temp = Property_Temperature(node, id='watertemp', name='Water Temp', unit='C') node.add_property(self.water_temp) self.mode_run_time = Property_String(node, id='moderuntime', name='Mode Run Time') node.add_property(self.mode_run_time) self.start()
def __init__(self, device_id=None, name=None, homie_settings=None, mqtt_settings=None): super().__init__(device_id, name, homie_settings, mqtt_settings) node = (Node_Base(self, 'status', 'Status', 'status')) self.add_node(node) self.register_status_properties(node) self.start()
def __init__(self, isy_device=None, homie_settings=None, mqtt_settings=None): Base.__init__(self, isy_device) Device_Base.__init__(self, self.get_homie_device_id(), isy_device.name, homie_settings, mqtt_settings) node = (Node_Base(self, 'program', 'Program', 'program')) self.add_node(node) self.status = Property_String(node, 'status', 'Status') node.add_property(self.status) self.run = Property_Enum(node, id='run', name='Run Program', data_format='RUNIF,RUNTHEN,RUNELSE,STOP', set_value=self.set_run_program) node.add_property(self.run) self.start()
node_config[node[0]]['location_status'].value = node_config[ node[0]]['enableLocation'] node_config[node[0]]['location_cache'].value = node_config[ node[0]]['cachedLocation'] get_config() iCloud = Device_Base(device_id='icloud-bridge', name='iCloud Homie Bridge', mqtt_settings=mqtt_config) for node in node_config.items(): node_id = node[0] lstatus_handler = lambda value: location_status_handler(node_id, value) node_config[node[0]]['node'] = Node_Base(iCloud, node[0], node[0].title(), node[0]) iCloud.add_node(node_config[node[0]]['node']) node_config[node[0]]['battery_status'] = Property_String( node_config[node[0]]['node'], id="batterystatus", name="%s Battery Status" % (node[0].title()), settable=False, value=None) node_config[node[0]]['node'].add_property( node_config[node[0]]['battery_status']) node_config[node[0]]['battery_level'] = Property_Float( node_config[node[0]]['node'], id="batterylevel", name="%s Battery Level" % (node[0].title()), settable=False,
def __init__(self, device_id=None, name=None, sensor_settings={}, homie_settings=None, mqtt_settings=None): super().__init__(device_id, name, homie_settings, mqtt_settings) # assign sensor try: sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY) except IOError: sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY) #sensor.set_humidity_oversample(bme680.OS_2X) sensor.set_humidity_oversample(bme680.OS_8X) #sensor.set_pressure_oversample(bme680.OS_4X) #sensor.set_temperature_oversample(bme680.OS_8X) #sensor.set_filter(bme680.FILTER_SIZE_3) #sensor.set_gas_status(bme680.ENABLE_GAS_MEAS) sensor.set_gas_heater_temperature(320) sensor.set_gas_heater_duration(150) sensor.select_gas_heater_profile(0) self._sensor = sensor self._sensor_settings.update(sensor_settings) # assign Homie features to update/request information on demand node_worker = Node_Base(self, id="worker-node", name="Data worker node", type_="status") self.add_node(node_worker) upd_interval = Property_Integer(node=node_worker, id="update-interval", name="Statistics update interval", unit="s", settable=True, set_value=self._set_upd_interval, value=self._upd_interval, data_format="5:3600") node_worker.add_property(upd_interval) ideal_rel_humidity = Property_Integer(node=node_worker, id="update-ideal-rel-humidity", name="Update ideal relative humidity for AQI calculations", unit="%", settable=True, set_value=self._set_ideal_rel_humidity, value=self._ideal_rel_humidity, data_format="0:100") node_worker.add_property(ideal_rel_humidity) # assign Homie features to base sensor node_sensor = Node_Base(self, id="multi-sensor", name="Multiple sensor", type_="status") self.add_node(node_sensor) pressure_prop = Property_Pressure(node=node_sensor, unit="hPa") node_sensor.add_property(pressure_prop) pressure_bias_prop = Property_Pressure(node=node_sensor, id="pressure-bias", unit="hPa", settable=False, value=self._sensor_settings["pressure_bias"]) node_sensor.add_property(pressure_bias_prop) self._pressure = pressure_prop humidity_prop = Property_Humidity(node=node_sensor) node_sensor.add_property(humidity_prop) humidity_bias_prop = Property_Humidity(node=node_sensor, id="humidity-bias", settable=False, value=self._sensor_settings["humidity_bias"]) node_sensor.add_property(humidity_bias_prop) self._humidity = humidity_prop temperature_prop = Property_Temperature(node=node_sensor, unit="°C") node_sensor.add_property(temperature_prop) temperature_bias_prop = Property_Temperature(node=node_sensor, id="temperature-bias", unit="°C", settable=False, value=self._sensor_settings["temperature_bias"]) node_sensor.add_property(temperature_bias_prop) self._temperature = temperature_prop gas_res_prop = Property_Float(node=node_sensor, id="gas-resistance", name="Gas resistance", settable=False, unit="Ohm") node_sensor.add_property(gas_res_prop) self._gas_resistance = gas_res_prop aqi_prop = Property_Integer(node=node_sensor, id="aqi", name="Air quality index", settable=False) node_sensor.add_property(aqi_prop) self._aqi = aqi_prop # start self.start()
def __init__( self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, thermostat_settings=THERMOSTAT_SETTINGS, ): super().__init__(device_id, name, homie_settings, mqtt_settings) node = Node_Base(self, "controls", "Controls", "controls") self.add_node(node) if "heat_setpoint" in thermostat_settings: heat_setpt_limits = "{}:{}".format( thermostat_settings["min_heat_setpoint"], thermostat_settings["max_heat_setpoint"], ) self.heat_setpoint = Property_Setpoint( node, id="heatsetpoint", name="Heat Setpoint", data_format=heat_setpt_limits, unit=thermostat_settings["units"], value=thermostat_settings["heat_setpoint"], set_value=self.set_heat_setpoint, ) node.add_property(self.heat_setpoint) if "cool_setpoint" in thermostat_settings: cool_setpt_limits = "{}:{}".format( thermostat_settings["min_cool_setpoint"], thermostat_settings["max_cool_setpoint"], ) self.cool_setpoint = Property_Setpoint( node, id="coolsetpoint", name="Cool Setpoint", data_format=cool_setpt_limits, unit=thermostat_settings["units"], value=thermostat_settings["cool_setpoint"], set_value=self.set_cool_setpoint, ) node.add_property(self.cool_setpoint) if "system_mode" in thermostat_settings: self.system_mode = Property_Enum( node, id="systemmode", name="System Mode", data_format=",".join(thermostat_settings["system_modes"]), value=thermostat_settings["system_mode"], set_value=self.set_system_mode, ) node.add_property(self.system_mode) if "fan_mode" in thermostat_settings: self.fan_mode = Property_Enum( node, id="fanmode", name="Fan Mode", data_format=",".join(thermostat_settings["fan_modes"]), value=thermostat_settings["fan_mode"], set_value=self.set_fan_mode, ) node.add_property(self.fan_mode) if "hold_mode" in thermostat_settings: self.hold_mode = Property_Enum( node, id="holdmode", name="Hold Mode", data_format=",".join(thermostat_settings["hold_modes"]), value=thermostat_settings["hold_mode"], set_value=self.set_hold_mode, ) node.add_property(self.hold_mode) node = Node_Base(self, "status", "Status", "status") self.add_node(node) self.current_temperture = Property_Temperature( node, unit=thermostat_settings["units"], value=thermostat_settings["current_temperature"], ) node.add_property(self.current_temperture) self.current_humidity = Property_Humidity( node, value=thermostat_settings["current_humidity"] ) node.add_property(self.current_humidity) self.system_status = Property_String( node, id="systemstatus", name="System Status", value=thermostat_settings["system_status"], ) node.add_property(self.system_status) self.start()
def __init__(self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, tstat_device=None): super().__init__ (device_id, name, homie_settings, mqtt_settings) self.tstat_device=tstat_device node = (Node_Base(self,'controls','Controls','controls')) self.add_node (node) self.heat_setpoint = Property_Setpoint (node,id='heatsetpoint',name='Heat Setpoint',data_format=SETPOINT_LIMITS,unit=UNITS,value=tstat_device.t_heat['raw'],set_value = lambda value: self.set_heat_setpoint(value) ) node.add_property (self.heat_setpoint) self.cool_setpoint = Property_Setpoint (node,id='coolsetpoint',name='Cool Setpoint',data_format=SETPOINT_LIMITS,unit=UNITS,value=tstat_device.t_cool['raw'],set_value=lambda value: self.set_cool_setpoint(value) ) node.add_property (self.cool_setpoint) self.system_mode = Property_Enum (node,id='systemmode',name='System Mode',data_format=','.join(SYSTEM_MODES),value=tstat_device.tmode['human'],set_value = lambda value: self.set_system_mode(value) ) node.add_property (self.system_mode) self.fan_mode = Property_Enum (node,id='fanmode',name='Fan Mode',data_format=','.join(FAN_MODES),value=tstat_device.fmode['human'],set_value = lambda value: self.set_fan_mode(value) ) node.add_property (self.fan_mode) self.hold = Property_Enum (node,id='hold',name='Hold',data_format=','.join(HOLD_MODES),value=tstat_device.hold['human'],set_value = lambda value: self.set_hold(value) ) node.add_property (self.hold) self.override = Property_Enum (node,id='override',name='Override',data_format=','.join(HOLD_MODES),value=tstat_device.override['human'],set_value = lambda value: self.set_override(value) ) node.add_property (self.override) node = (Node_Base(self,'status','Status','status')) self.add_node (node) self.temperature = Property_Temperature (node,unit='F',value=tstat_device.temp['raw']) node.add_property (self.temperature) self.system_status = Property_String (node,id='systemstatus',name='System Status',value=tstat_device.tstate['human']) node.add_property (self.system_status) self.fan_status = Property_String (node,id='fanstatus',name='Fan Status',value=tstat_device.fstate['human']) node.add_property (self.fan_status) node = (Node_Base(self,'runtime','Runtime','runtime')) self.add_node (node) self.today_heat = Property_String (node,id='todayheat',name='Today Heat') node.add_property (self.today_heat) self.today_cool = Property_String (node,id='todaycool',name='Today Cool') node.add_property (self.today_cool) self.today_total = Property_String (node,id='todaytotal',name='Today Total') node.add_property (self.today_total) self.yesterday_heat = Property_String (node,id='yesterdayheat',name='Yesterday Heat') node.add_property (self.yesterday_heat) self.yesterday_cool = Property_String (node,id='yesterdaycool',name='Yesterday Cool') node.add_property (self.yesterday_cool) self.yesterday_total = Property_String (node,id='yesterdaytotal',name='Yesterday Total') node.add_property (self.yesterday_total) self.start()
def __init__(self, atag: AtagOne, eventloop, device_id="atagone", name="Atag One"): """Create an ATAG ONE Homie device.""" super().__init__(device_id, name, TRANSLATED_HOMIE_SETTINGS, TRANSLATED_MQTT_SETTINGS) self.atag: AtagOne = atag self.temp_unit = atag.climate.temp_unit self._eventloop = eventloop LOGGER.debug("Setting up Homie nodes") node = (Node_Base(self, 'burner', 'Burner', 'status')) self.add_node(node) self.burner_modulation = Property_Integer(node, id="modulation", name="Burner modulation", settable=False) node.add_property(self.burner_modulation) self.burner_target = Property_Enum(node, id="target", name="Burner target", settable=False, data_format="none,ch,dhw") node.add_property(self.burner_target) # Central heating status properties node = (Node_Base(self, 'centralheating', 'Central heating', 'status')) self.add_node(node) self.ch_status = Property_Boolean(node, id="status", name="CH status", settable=False) node.add_property(self.ch_status) self.ch_temperature = Property_Temperature( node, id="temperature", name="CH temperature", settable=False, value=self.atag.climate.temperature, unit=self.temp_unit) node.add_property(self.ch_temperature) self.ch_water_temperature = Property_Temperature( node, id="water-temperature", name="CH water temperature", settable=False, value=self.atag.report["CH Water Temperature"].state, unit=self.temp_unit) node.add_property(self.ch_water_temperature) self.ch_target_water_temperature = Property_Temperature( node, id="target-water-temperature", name="CH target water temperature", settable=False, value=self.atag.climate.target_temperature, unit=self.temp_unit) node.add_property(self.ch_target_water_temperature) self.ch_return_water_temperature = Property_Temperature( node, id="return-water-temperature", name="CH return water temperature", settable=False, value=self.atag.report["CH Return Temperature"].state, unit=self.temp_unit) node.add_property(self.ch_return_water_temperature) self.ch_water_pressure = Property_Float( node, id="water-pressure", name="CH water pressure", settable=False, value=self.atag.report["CH Water Pressure"].state, unit=self.temp_unit) node.add_property(self.ch_water_pressure) ch_mode_values = ",".join(STATES["ch_mode"].values()) self.ch_mode = Property_Enum(node, id="mode", name="CH mode", settable=False, value=self.atag.climate.preset_mode, data_format=ch_mode_values) node.add_property(self.ch_mode) self.ch_mode_duration = Property_String( node, id="mode-duration", name="CH mode duration", settable=False, value=self.atag.climate.preset_mode_duration, ) node.add_property(self.ch_mode_duration) # Domestic hot water status properties node = (Node_Base(self, 'domestichotwater', 'Domestic hot water', 'status')) self.add_node(node) self.dhw_status = Property_Boolean(node, id="status", name="DHW status", settable=False) node.add_property(self.dhw_status) self.dhw_temperature = Property_Temperature( node, id="temperature", name="DHW temperature", settable=False, value=self.atag.dhw.temperature, unit=self.temp_unit) node.add_property(self.dhw_temperature) dhw_mode_values = ",".join(STATES["dhw_mode"].values()) + ",off" self.dhw_mode = Property_Enum(node, id="mode", name="DHW mode", settable=False, value=self.atag.dhw.current_operation, data_format=dhw_mode_values) node.add_property(self.dhw_mode) node = (Node_Base(self, 'weather', 'Weather', 'status')) self.add_node(node) self.weather_temperature = Property_Temperature( node, id="temperature", name="Weather temperature", settable=False, value=self.atag.report["weather_temp"].state, unit=self.temp_unit) node.add_property(self.weather_temperature) # Control properties node = (Node_Base(self, 'controls', 'Controls', 'controls')) self.add_node(node) ch_min_temp = 12 ch_max_temp = 25 ch_target_temperature_limits = f'{ch_min_temp}:{ch_max_temp}' self.ch_target_temperature = Property_Setpoint( node, id='ch-target-temperature', name='CH Target temperature', data_format=ch_target_temperature_limits, unit=self.temp_unit, value=self.atag.climate.target_temperature, set_value=self.set_ch_target_temperature) node.add_property(self.ch_target_temperature) dhw_min_temp = self.atag.dhw.min_temp dhw_max_temp = self.atag.dhw.max_temp dhw_target_temperature_limits = f'{dhw_min_temp}:{dhw_max_temp}' self.dhw_target_temperature = Property_Setpoint( node, id='dhw-target-temperature', name='DHW Target temperature', data_format=dhw_target_temperature_limits, unit=self.temp_unit, value=self.atag.dhw.target_temperature, set_value=self.set_dhw_target_temperature) node.add_property(self.dhw_target_temperature) hvac_values = ",".join(STATES["ch_control_mode"].values()) self.hvac_mode = Property_Enum(node, id='hvac-mode', name='HVAC mode', data_format=hvac_values, unit=self.temp_unit, value=self.atag.climate.hvac_mode, set_value=self.set_hvac_mode) node.add_property(self.hvac_mode) ch_mode_values = ",".join(STATES["ch_mode"].values()) self.ch_mode_control = Property_Enum( node, id="ch-mode", name="CH mode", data_format=ch_mode_values, value=self.atag.climate.preset_mode, set_value=self.set_ch_mode) node.add_property(self.ch_mode_control) LOGGER.debug("Starting Homie device") self.start()
def __init__( self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, sensors_definition = comfoairq_sensors, comfoconnect_settings=None, ): assert comfoconnect_settings assert mqtt_settings super().__init__ (device_id, name, homie_settings, mqtt_settings) self.state = 'init' global repeating_timer if repeating_timer == None: repeating_timer = Repeating_Timer( self.homie_settings["update_interval"] ) repeating_timer.add_callback(self.publish_connection_status) self.sensors = sensors_definition self.comfoconnect_settings=comfoconnect_settings self.min_low_flow = self.comfoconnect_settings['COMFOCONNECT_MIN_LOW_FLOW'] self.max_high_flow = self.comfoconnect_settings['COMFOCONNECT_MAX_HIGH_FLOW'] self.comfoairq = ComfoAirQ(comfoconnect_settings=self.comfoconnect_settings) self.comfoairq.callback_sensor = self.callback_sensor self.comfoairq.add_on_state_change_callback(self.publish_connection_status) # Sensors node = Node_Base(self,'sensors','Sensors','sensors') self.add_node (node) for comfoairq_sensor in self.sensors: self.comfoairq.register_sensor(comfoairq_sensor) for homie_sensor in self.sensors[comfoairq_sensor]: sensor_id ,sensor_name ,sensor_type, transformation_function, function_args = homie_sensor if sensor_type == 'temperature': node.add_property (Property_Temperature (node,id=sensor_id,name = sensor_name, unit='°C')) elif sensor_type == 'fan_speed': node.add_property (Property_Float (node,id=sensor_id,name = sensor_name,settable = False,unit='rpm')) elif sensor_type == 'fan_flow': node.add_property (Property_Float (node,id=sensor_id,name = sensor_name,settable = False,unit='m³/h')) elif sensor_type == 'percentage': node.add_property (Property_Float (node,id=sensor_id,name = sensor_name,settable = False,unit='%')) elif sensor_type == 'mode_end_date': node.add_property (Property_DateTime (node,id=sensor_id,name = sensor_name,settable = False,data_format='%Y-%m-%d %H:%M:%S.%f')) elif sensor_type == 'mode_timer': node.add_property (Property_Integer (node,id=sensor_id,name = sensor_name,settable = False,unit='s')) elif sensor_type == 'enum': node.add_property (Property_Enum (node,id=sensor_id,name = sensor_name,settable = False,data_format=','.join(function_args.values()))) elif sensor_type == 'power_current': node.add_property (Property_Float (node,id=sensor_id,name = sensor_name,settable = False,unit='W')) elif sensor_type == 'energy': node.add_property (Property_Float (node,id=sensor_id,name = sensor_name,settable = False,unit='kWh')) elif sensor_type == 'integer': node.add_property (Property_Integer(node,id=sensor_id,name = sensor_name,settable = False)) # Sensors managed same way as Controls node.add_property(Property_Enum (node,id='current-mode',name ='Current Mode',settable = False,data_format=','.join(CURRENT_OPERATING_MODE_SENSOR_VALUES.values()))) self.add_controls_callback(SENSOR_OPERATING_MODE_BIS,self.update_current_mode) self.add_controls_callback(SENSOR_OPERATING_MODE,self.update_current_mode) # Controls node = Node_Base(self,'controls','Controls','controls') self.add_node (node) # FAN SPEED MODE node.add_property(Property_Enum (node,id='fan-mode',name='Fan Mode',data_format=','.join(FAN_MODES.keys()),set_value = lambda value: self.set_fan_mode(value))) self.add_controls_callback(SENSOR_FAN_SPEED_MODE,self.update_fan_mode) # BYPASS MODE (for 1 hour) node.add_property(Property_Enum (node,id='bypass-mode',name='Bypass Mode',data_format=','.join(BYPASS_MODES.keys()),set_value = lambda value: self.set_bypass_mode(value))) self.add_controls_callback(SENSOR_BYPASS_MODE,self.update_bypass_mode) # BYPASS ON node.add_property(Property_Integer (node,id='bypass-on', name='Bypass On',data_format='0:'+ str(0xffffffff),set_value = lambda value: self.set_bypass_on(value))) # BYPASS OFF node.add_property(Property_Integer (node,id='bypass-off', name='Bypass Off',data_format='0:'+ str(0xffffffff),set_value = lambda value: self.set_bypass_off(value))) self.add_controls_callback(SENSOR_BYPASS_MODE,self.update_bypass) self.add_controls_callback(SENSOR_BYPASS_TIMER,self.update_bypass) # TEMPERATURE PROFILE node.add_property(Property_Enum (node,id='temperature-profile',name='Temperature Profile',data_format=','.join(TEMPERATURE_PROFILES.keys()),set_value = lambda value: self.set_temperature_profile(value))) self.add_controls_callback(SENSOR_TEMPERATURE_PROFILE,self.update_temperature_profile) # OPERATING MODE node.add_property(Property_Enum (node,id='operating-mode',name='Operating Mode',data_format=','.join(OPERATING_MODES.keys()),set_value = lambda value: self.set_operating_mode(value))) self.add_controls_callback(SENSOR_OPERATING_MODE,self.update_operating_mode) # Manual MODE node.add_property(Property_Switch (node,id='manual-mode',name='Manual Mode',set_value = lambda value: self.set_manual_mode(value))) self.add_controls_callback(SENSOR_OPERATING_MODE,self.update_manual_mode) # VENT MODE node.add_property(Property_Enum (node,id='vent-mode',name='Ventilation Mode',data_format=','.join(VENT_MODES.keys()),set_value = lambda value: self.set_vent_mode(value))) self.add_controls_callback(SENSOR_TEMPORARY_STOP_EXHAUST_FAN_STATE,self.update_vent_mode) self.add_controls_callback(SENSOR_TEMPORARY_STOP_SUPPLY_FAN_STATE,self.update_vent_mode) # SUPPLY FAN OFF node.add_property(Property_Integer (node,id='supply-fan-off', name='Supply Fan Off',data_format='0:'+ str(0xffffffff),set_value = lambda value: self.set_supply_fan_off(value))) self.add_controls_callback(SENSOR_SUPPLY_FAN_TIMER,self.update_supply_fan_off) # EXHAUST FAN OFF node.add_property(Property_Integer (node,id='exhaust-fan-off', name='Exhaust Fan Off',data_format='0:'+ str(0xffffffff),set_value = lambda value: self.set_exhaust_fan_off(value))) self.add_controls_callback(SENSOR_EXHAUST_FAN_TIMER,self.update_exhaust_fan_off) # BOOST MODE node.add_property(Property_Integer (node,id='boost-mode',name='Activate Scheduled Boost Mode',data_format='0:'+ str(0xffffffff),set_value = lambda value: self.set_boost_mode(value))) self.add_controls_callback(SENSOR_OPERATING_MODE_BIS,self.update_boost_mode) self.add_controls_callback(SENSOR_FAN_NEXT_CHANGE,self.update_boost_mode) # AWAY MODE node.add_property(Property_Integer (node,id='away-mode',name='Activate Scheduled Away Mode',data_format='0:'+ str(0xffffffff),set_value = lambda value: self.set_away_mode(value))) self.add_controls_callback(SENSOR_OPERATING_MODE_BIS,self.update_away_mode) self.add_controls_callback(SENSOR_FAN_NEXT_CHANGE,self.update_away_mode) # Heating Season detection RMOT node.add_property(Property_Temperature (node,id='heating-rmot',name='Heating Limit RMOT',data_format='0:20',unit='°C',settable = True, set_value = lambda value: self.set_heating_rmot(value))) self.comfoairq.add_on_state_change_callback(self.update_heating_rmot) repeating_timer.add_callback(self.update_heating_rmot) # Cooling Season detection RMOT node.add_property(Property_Temperature (node,id='cooling-rmot',name='Cooling Limit RMOT',data_format='20:40',unit='°C',settable = True, set_value = lambda value: self.set_cooling_rmot(value))) self.comfoairq.add_on_state_change_callback(self.update_cooling_rmot) repeating_timer.add_callback(self.update_cooling_rmot) #Temperature passive node.add_property(Property_Enum (node,id='temperature-passive',name='Temperature Passive',data_format=','.join(SENSOR_VENTILATION),set_value = lambda value: self.set_temperature_passive(value))) self.comfoairq.add_on_state_change_callback(self.update_temperature_passive) repeating_timer.add_callback(self.update_temperature_passive) #Humidity comfort node.add_property(Property_Enum (node,id='humidity-comfort',name='Humidity Comfort',data_format=','.join(SENSOR_VENTILATION),set_value = lambda value: self.set_humidity_comfort(value))) self.comfoairq.add_on_state_change_callback(self.update_humidity_comfort) repeating_timer.add_callback(self.update_humidity_comfort) #Humidity protection node.add_property(Property_Enum (node,id='humidity-protection',name='Humidity Protection',data_format=','.join(SENSOR_VENTILATION),set_value = lambda value: self.set_humidity_protection(value))) self.comfoairq.add_on_state_change_callback(self.update_humidity_protection) repeating_timer.add_callback(self.update_humidity_protection) #Flow unbalance node.add_property(Property_Float (node,id='unbalance',name='Flow Unbalance',data_format='-15:15',set_value = lambda value: self.set_unbalance(value))) self.comfoairq.add_on_state_change_callback(self.update_unbalance) repeating_timer.add_callback(self.update_unbalance) #Flow Away node.add_property(Property_Integer (node,id='flow-away',name='Flow Away Speed',data_format='0:' + str(self.max_high_flow),set_value = lambda value: self.set_flow_away(value))) self.comfoairq.add_on_state_change_callback(self.update_flow_away) repeating_timer.add_callback(self.update_flow_away) #Flow Low node.add_property(Property_Integer (node,id='flow-low',name='Flow Low Speed',data_format= str(self.min_low_flow) + ':' + str(self.max_high_flow),set_value = lambda value: self.set_flow_low(value))) self.comfoairq.add_on_state_change_callback(self.update_flow_low) repeating_timer.add_callback(self.update_flow_low) #Flow Medium node.add_property(Property_Integer (node,id='flow-medium',name='Flow Medium Speed',data_format=str(self.min_low_flow) + ':' + str(self.max_high_flow),set_value = lambda value: self.set_flow_medium(value))) self.comfoairq.add_on_state_change_callback(self.update_flow_medium) repeating_timer.add_callback(self.update_flow_medium) #Flow High node.add_property(Property_Integer (node,id='flow-high',name='Flow High Speed',data_format=str(self.min_low_flow) + ':' + str(self.max_high_flow),set_value = lambda value: self.set_flow_high(value))) self.comfoairq.add_on_state_change_callback(self.update_flow_high) repeating_timer.add_callback(self.update_flow_high) self.start() self.publish_connection_status()
def __init__(self, device_id=None, name=None, homie_settings=None, mqtt_settings=None, tcc_device=None): super().__init__ (device_id, name, homie_settings, mqtt_settings) self.tcc_device=tcc_device node = (Node_Base(self,'controls','Controls','controls')) self.add_node (node) heat_setpt_limits = '{}:{}'.format(tcc_device.raw_ui_data['HeatLowerSetptLimit'],tcc_device.raw_ui_data['HeatUpperSetptLimit']) self.heat_setpoint = Property_Setpoint (node,id='heatsetpoint',name='Heat Setpoint',data_format=heat_setpt_limits,unit=tcc_device.temperature_unit,value=tcc_device.setpoint_heat,set_value = lambda value: self.set_heat_setpoint(value) ) node.add_property (self.heat_setpoint) cool_setpt_limits = '{}:{}'.format(tcc_device.raw_ui_data['CoolLowerSetptLimit'],tcc_device.raw_ui_data['CoolUpperSetptLimit']) self.cool_setpoint = Property_Setpoint (node,id='coolsetpoint',name='Cool Setpoint',data_format=cool_setpt_limits,unit=tcc_device.temperature_unit,value=tcc_device.setpoint_cool,set_value=lambda value: self.set_cool_setpoint(value) ) node.add_property (self.cool_setpoint) self.system_mode = Property_Enum (node,id='systemmode',name='System Mode',data_format=','.join(SYSTEM_MODES),value=tcc_device.system_mode,set_value = lambda value: self.set_system_mode(value) ) node.add_property (self.system_mode) self.fan_mode = Property_Enum (node,id='fanmode',name='Fan Mode',data_format=','.join(FAN_MODES),value=tcc_device.fan_mode,set_value = lambda value: self.set_fan_mode(value) ) node.add_property (self.fan_mode) # self.hold_mode = Property_Enum (node,id='holdmode',name='Hold Mode',data_format=','.join(HOLD_MODES),value=self.get_hold_mode(),set_value = lambda value: self.set_hold_mode(value) ) self.hold_mode = Property_String (node,id='holdmode',name='Hold Mode',settable=True,value=self.get_hold_mode(),set_value = lambda value: self.set_hold_mode(value) ) node.add_property (self.hold_mode) self.temp_hold_time = Property_Integer (node,id='tempholdtime',name='Temporary Hold Hours',data_format='1:24',settable=True,value=Default_Temporay_Hold_Hours,set_value = lambda value: self.set_temp_hold_time(value) ) node.add_property (self.temp_hold_time) self.request_refresh = Property_Button (node,id='requestrefresh',name='Request Refresh',settable=True,set_value = lambda value: self.update() ) node.add_property (self.request_refresh) node = (Node_Base(self,'status','Status','status')) self.add_node (node) self.temperture = Property_Temperature (node,unit=tcc_device.temperature_unit) node.add_property (self.temperture) self.humidity = Property_Humidity (node) node.add_property (self.humidity) self.system_status = Property_String (node,id='systemstatus',name='System Status',value=tcc_device.equipment_output_status) node.add_property (self.system_status) self.account_status = Property_String (node,id='accountstatus',name='Account Status',value='Connected') node.add_property (self.account_status) self.last_update = Property_String (node,id='lastupdate',name='Last Update',value=datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")) node.add_property (self.last_update) node = (Node_Base(self,'outside','Outside','status')) self.add_node (node) self.outside_temperature = Property_Temperature (node,name='Outside Temperature',unit=tcc_device.temperature_unit) node.add_property (self.outside_temperature) self.outside_humidity = Property_Humidity (node,name='Outside Humidity') node.add_property (self.outside_humidity) self.start()
def __init__(self, item_config, device_id="viessmann", name="Viessmann Heizung", homie_settings=None, mqtt_settings=MQTT_DEFAULT_SETTINGS, vc=None ): super().__init__(device_id, name, homie_settings, mqtt_settings) self.vcomm=vc node = Node_Base(self, "generic", "Generic", "generic") self.add_node(node) for item in item_config: if item.type == 'enum': enum_item = Property_Enum( node, id=item.name.lower(), name=item.name, settable=item.settable, data_format=",".join(item.enum), value=item.value, set_value=self.set_value if item.settable else None ) node.add_property(enum_item) item.property = enum_item # self.items[item.name] = item elif item.type == 'short': value = float(item.value) short_item = Property_Temperature( node, id=item.name.lower(), name=item.name, settable=item.settable, data_format="-150:150", value=value, unit=item.unit, set_value=self.set_value if item.settable else None ) node.add_property(short_item) item.property = short_item elif item.type == 'int' or item.type == 'uint': value = int(float(item.value)) int_value = Property_Integer( node, id=item.name.lower(), name=item.name, settable=item.settable, value=value, unit=item.unit, set_value=self.set_value if item.settable else None ) node.add_property(int_value) item.property = int_value elif item.type == 'systime': value = item.value string_value = Property_String( node, id=item.name.lower(), name=item.name, settable=item.settable, value=value, unit=item.unit, set_value=self.set_value if item.settable else None ) node.add_property(string_value) item.property = string_value else: logger.info("Unknown item: " + item.__dict__) logger.info('done') self.start()
def __init__(self, atag: AtagDataStore, eventloop, device_id="atagone", name=None): """Create an ATAG ONE device.""" super().__init__(device_id, name, TRANSLATED_HOMIE_SETTINGS, TRANSLATED_MQTT_SETTINGS) self._eventloop = eventloop self.atag: AtagDataStore = atag self.temp_unit = "°C" node = (Node_Base(self, 'burner', 'Burner', 'status')) self.add_node(node) self.burner_modulation = Property_Integer(node, id="modulation", name="Burner modulation", settable=False) node.add_property(self.burner_modulation) self.burner_target = Property_Enum(node, id="target", name="Burner target", settable=False, data_format="none,ch,dhw") node.add_property(self.burner_target) # Central heating status properties node = (Node_Base(self, 'centralheating', 'Central heating', 'status')) self.add_node(node) self.ch_status = Property_Boolean(node, id="status", name="CH status", settable=False) node.add_property(self.ch_status) self.ch_temperature = Property_Temperature(node, id="temperature", name="CH temperature", settable=False, value=self.atag.temperature) node.add_property(self.ch_temperature) self.ch_water_temperature = Property_Temperature( node, id="water-temperature", name="CH water temperature", settable=False, value=self.atag.sensordata['ch_water_temp'].get('state', 0)) node.add_property(self.ch_water_temperature) self.ch_target_water_temperature = Property_Temperature( node, id="target-water-temperature", name="CH target water temperature", settable=False, value=self.atag.sensordata['ch_setpoint'].get('state', 0)) node.add_property(self.ch_target_water_temperature) self.ch_return_water_temperature = Property_Temperature( node, id="return-water-temperature", name="CH return water temperature", settable=False, value=self.atag.sensordata['ch_return_temp'].get('state', 0)) node.add_property(self.ch_return_water_temperature) self.ch_water_pressure = Property_Float( node, id="water-pressure", name="CH water pressure", settable=False, value=self.atag.sensordata['ch_water_pres'].get('state', 0)) node.add_property(self.ch_water_pressure) # Domestic hot water status properties node = (Node_Base(self, 'domestichotwater', 'Domestic hot water', 'status')) self.add_node(node) self.dhw_status = Property_Boolean(node, id="status", name="DHW status", settable=False) node.add_property(self.dhw_status) self.dhw_temperature = Property_Temperature( node, id="temperature", name="DHW temperature", settable=False, value=self.atag.dhw_temperature) node.add_property(self.dhw_temperature) node = (Node_Base(self, 'weather', 'Weather', 'status')) self.add_node(node) self.weather_temperature = Property_Temperature( node, id="temperature", name="Weather temperature", settable=False, value=self.atag.sensordata['weather_temp'].get('state', 0)) node.add_property(self.weather_temperature) # Control properties node = (Node_Base(self, 'controls', 'Controls', 'controls')) self.add_node(node) ch_min_temp = 12 ch_max_temp = 25 ch_target_temperature_limits = f'{ch_min_temp}:{ch_max_temp}' self.ch_target_temperature = Property_Setpoint( node, id='ch-target-temperature', name='CH Target temperature', data_format=ch_target_temperature_limits, unit=self.temp_unit, value=self.atag.target_temperature, set_value=self.set_ch_target_temperature) node.add_property(self.ch_target_temperature) dhw_min_temp = self.atag.dhw_min_temp dhw_max_temp = self.atag.dhw_max_temp dhw_target_temperature_limits = f'{dhw_min_temp}:{dhw_max_temp}' self.dhw_target_temperature = Property_Setpoint( node, id='dhw-target-temperature', name='DHW Target temperature', data_format=dhw_target_temperature_limits, unit=self.temp_unit, value=self.atag.dhw_target_temperature, set_value=self.set_dhw_target_temperature) node.add_property(self.dhw_target_temperature) hvac_values = "auto,heat" self.hvac_mode = Property_Enum(node, id='hvac-mode', name='HVAC mode', data_format=hvac_values, value=self.atag.hvac_mode, set_value=self.set_hvac_mode) node.add_property(self.hvac_mode) self.start()