ffw changed to new devdi concept

This commit is contained in:
Dirk Alders 2025-08-26 20:49:30 +02:00
parent 5d26fc11d6
commit 820fb707c9
2 changed files with 64 additions and 170 deletions

View File

@ -36,7 +36,7 @@ class all_functions(room_collection):
# ground floor west # ground floor west
self.gfw = ground_floor_west(self.mqtt_client, pd) self.gfw = ground_floor_west(self.mqtt_client, pd)
# first floor west # first floor west
self.ffw = first_floor_west(self.mqtt_client, pd) self.ffw = first_floor_west(self.mqtt_client)
# first floor east # first floor east
self.ffe = first_floor_east(self.mqtt_client) self.ffe = first_floor_east(self.mqtt_client)
# #
@ -75,9 +75,9 @@ class all_functions(room_collection):
self.ffe.sleep.input_device.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe.all_off) self.ffe.sleep.input_device.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe.all_off)
# FFW ALL OFF - Long push ffw_floor # FFW ALL OFF - Long push ffw_floor
self.ffw.floor.main_light_shelly.add_callback(self.ffw.floor.main_light_shelly.KEY_LONGPUSH_0, self.ffw.floor.switch_main_light.add_callback(self.ffw.floor.switch_main_light.KEY_LONGPUSH_0,
True, self.ffw.floor.main_light_shelly.flash_0_mcb) True, self.ffw.floor.switch_main_light.flash_0_mcb)
self.ffw.floor.main_light_shelly.add_callback(self.ffw.floor.main_light_shelly.KEY_LONGPUSH_0, True, self.ffw.all_off) self.ffw.floor.switch_main_light.add_callback(self.ffw.floor.switch_main_light.KEY_LONGPUSH_0, True, self.ffw.all_off)
def init_sumer_winter_mode(self): def init_sumer_winter_mode(self):
# ALL summer/winter mode # ALL summer/winter mode

View File

@ -3,11 +3,10 @@
# #
import config import config
from devdi import topic as props from devdi import rooms
from function.db import get_radiator_data, set_radiator_data from function.db import get_radiator_data, set_radiator_data
from function.modules import heating_function from function.modules import heating_function
from function.rooms import room, room_collection from function.rooms import room, room_collection
from function.videv import videv_switch_brightness, videv_switch_brightness_color_temp, videv_heating, videv_switching
import logging import logging
@ -17,210 +16,105 @@ except ImportError:
ROOT_LOGGER_NAME = 'root' ROOT_LOGGER_NAME = 'root'
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__) logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
loc = props.LOC_FFW
class first_floor_west(room_collection): class first_floor_west(room_collection):
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
super().__init__(mqtt_client) super().__init__(mqtt_client)
self.floor = first_floor_west_floor(mqtt_client, pd) self.floor = first_floor_west_floor(mqtt_client)
self.bath = first_floor_west_bath(mqtt_client, pd) self.bath = first_floor_west_bath(mqtt_client)
self.julian = first_floor_west_julian(mqtt_client, pd) self.julian = first_floor_west_julian(mqtt_client)
self.livingroom = first_floor_west_living(mqtt_client, pd) self.livingroom = first_floor_west_living(mqtt_client)
self.sleep = first_floor_west_sleep(mqtt_client, pd) self.sleep = first_floor_west_sleep(mqtt_client)
class first_floor_west_floor(room): class first_floor_west_floor(rooms.ffw_floor, room):
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
roo = props.ROO_FLO
#
# Device initialisation
#
# http://shelly1-58BF25D848EA
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
super().__init__(mqtt_client) super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
# #
# Virtual Device Interface # connect videv and switch
# self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
# main light
self.main_light = videv_switching(
mqtt_client, config.TOPIC_FFW_FLOOR_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0
)
class first_floor_west_julian(room): class first_floor_west_julian(rooms.ffw_julian, room):
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
roo = props.ROO_JUL
#
# Device initialisation
#
# http://shelly1l-3C6105E43452
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
# heating function
self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
super().__init__(mqtt_client) super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
# #
# Functionality initialisation # light <-> videv
# self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
self.videv_main_light.connect_ct_device(self.light_main_light, self.light_main_light.KEY_COLOR_TEMP)
# heating function # heating function
self.heating_function = heating_function( self.heating_function = heating_function(
self.heating_valve, self.valve_heating,
config.DEFAULT_TEMPERATURE, config.DEFAULT_TEMPERATURE,
**get_radiator_data(self.heating_valve.topic) **get_radiator_data(self.valve_heating.topic)
) )
self.heating_function.add_callback(None, None, set_radiator_data, True) self.heating_function.add_callback(None, None, set_radiator_data, True)
self.videv_heating.connect_heating_function(self.heating_function)
#
# Virtual Device Interface
#
# main light
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
)
# heating function
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_FFW_JULIAN_HEATING_VALVE_VIDEV,
self.heating_function
)
class first_floor_west_bath(room): class first_floor_west_bath(rooms.ffw_bath, room):
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
roo = props.ROO_BAT
#
# Device initialisation
#
# http://shelly1-58BF25D84219
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
# heating function
self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
super().__init__(mqtt_client) super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
#
# light <-> videv
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
#
# Functionality initialisation
#
# heating function # heating function
self.heating_function = heating_function( self.heating_function = heating_function(
self.heating_valve, self.valve_heating,
config.DEFAULT_TEMPERATURE, config.DEFAULT_TEMPERATURE,
**get_radiator_data(self.heating_valve.topic) **get_radiator_data(self.valve_heating.topic)
) )
self.heating_function.add_callback(None, None, set_radiator_data, True) self.heating_function.add_callback(None, None, set_radiator_data, True)
self.videv_heating.connect_heating_function(self.heating_function)
#
# Virtual Device Interface
#
# main light
self.main_light = videv_switching(
mqtt_client, config.TOPIC_FFW_BATH_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0
)
# heating function
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_VIDEV,
self.heating_function
)
class first_floor_west_living(room): class first_floor_west_living(rooms.ffw_livingroom, room):
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
roo = props.ROO_LIV
#
# Device initialisation
#
# http://shelly1l-84CCA8ACE6A1
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
# heating function
self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
super().__init__(mqtt_client) super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
#
# light <-> videv
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
self.videv_main_light.connect_ct_device(self.light_main_light, self.light_main_light.KEY_COLOR_TEMP)
#
# Functionality initialisation
#
# heating function # heating function
self.heating_function = heating_function( self.heating_function = heating_function(
self.heating_valve, self.valve_heating,
config.DEFAULT_TEMPERATURE, config.DEFAULT_TEMPERATURE,
**get_radiator_data(self.heating_valve.topic) **get_radiator_data(self.valve_heating.topic)
) )
self.heating_function.add_callback(None, None, set_radiator_data, True) self.heating_function.add_callback(None, None, set_radiator_data, True)
self.videv_heating.connect_heating_function(self.heating_function)
#
# Virtual Device Interface
#
# main light
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
)
# heating function
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_FFW_LIVINGROOM_HEATING_VALVE_VIDEV,
self.heating_function
)
class first_floor_west_sleep(room): class first_floor_west_sleep(rooms.ffw_sleep, room):
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
roo = props.ROO_SLP
#
# Device initialisation
#
# http://shelly1-3494546A51F2
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
# heating function
self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
# window light
self.window_light = pd.get(props.STG_ZFW, loc, roo, props.FUN_WIL)
super().__init__(mqtt_client) super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
#
# light <-> videv
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
#
self.videv_window_light.connect_sw_device(self.light_window_light, self.light_window_light.KEY_OUTPUT_0)
self.videv_window_light.connect_br_device(self.light_window_light, self.light_window_light.KEY_BRIGHTNESS)
self.videv_window_light.connect_ct_device(self.light_window_light, self.light_window_light.KEY_COLOR_TEMP)
# main light -> window light
self.switch_main_light.add_callback(self.switch_main_light.KEY_OUTPUT_0, None, self.light_window_light.set_output_0_mcb, True)
#
# Functionality initialisation
#
# heating function # heating function
self.heating_function = heating_function( self.heating_function = heating_function(
self.heating_valve, self.valve_heating,
config.DEFAULT_TEMPERATURE, config.DEFAULT_TEMPERATURE,
**get_radiator_data(self.heating_valve.topic) **get_radiator_data(self.valve_heating.topic)
) )
self.heating_function.add_callback(None, None, set_radiator_data, True) self.heating_function.add_callback(None, None, set_radiator_data, True)
self.videv_heating.connect_heating_function(self.heating_function)
# main light
self.main_light_shelly.add_callback(self.main_light_shelly.KEY_OUTPUT_0, None, self.window_light.set_output_0_mcb, True)
#
# Virtual Device Interface
#
# main light
self.main_light_videv = videv_switch_brightness(
mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS
)
# heating function
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_FFW_SLEEP_HEATING_VALVE_VIDEV,
self.heating_function
)
# window lamp
self.windowlamp_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFW_SLEEP_WINDOW_LAMP_VIDEV,
self.window_light, self.window_light.KEY_OUTPUT_0,
self.window_light, self.window_light.KEY_BRIGHTNESS,
self.window_light, self.window_light.KEY_COLOR_TEMP
)