ffe changed to new devdi concept

This commit is contained in:
Dirk Alders 2025-08-26 20:32:17 +02:00
parent 5d44e0e68d
commit 5d26fc11d6
5 changed files with 67 additions and 127 deletions

2
devdi

@ -1 +1 @@
Subproject commit 4fa00811c6d243888828e67b0952b5b06f46a3d7
Subproject commit 31c00259ded5a8a1204b73b48010b7766989e615

View File

@ -43,10 +43,12 @@ from devices.mydevices import powerplug as my_powerplug
from devices.mydevices import audio_status
from devices.mydevices import remote
from function.videv import videv_heating as videv_hea
from function.videv import videv_switch_brightness_color_temp as videv_sw_br_ct
from function.videv import videv_switch_brightness as videv_sw_br
from function.videv import videv_switching as videv_sw
from function.videv import videv_switch_brightness as videv_sw_br
from function.videv import videv_switch_brightness_color_temp as videv_sw_br_ct
from function.videv import videv_switching_timer as videv_sw_tm
from function.videv import videv_heating as videv_hea
from function.videv import videv_multistate
try:
from config import APP_NAME as ROOT_LOGGER_NAME

View File

@ -38,7 +38,7 @@ class all_functions(room_collection):
# first floor west
self.ffw = first_floor_west(self.mqtt_client, pd)
# first floor east
self.ffe = first_floor_east(self.mqtt_client, pd)
self.ffe = first_floor_east(self.mqtt_client)
#
# Interactions
#

View File

@ -3,13 +3,11 @@
#
import config
from devdi import topic as props
from devdi import rooms
from function.db import get_radiator_data, set_radiator_data
from function.helpers import day_event
from function.modules import brightness_choose_n_action, timer_on_activation, heating_function, switched_light
from function.rooms import room, room_collection
from function.videv import videv_switching, videv_switch_brightness, videv_switching_timer, videv_switch_brightness_color_temp, videv_heating, videv_multistate
import logging
try:
@ -18,16 +16,14 @@ except ImportError:
ROOT_LOGGER_NAME = 'root'
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
loc = props.LOC_FFE
class first_floor_east(room_collection):
def __init__(self, mqtt_client, pd):
def __init__(self, mqtt_client,):
super().__init__(mqtt_client)
self.dining = first_floor_east_dining(mqtt_client)
self.floor = first_floor_east_floor(mqtt_client)
self.kitchen = first_floor_east_kitchen(mqtt_client, pd)
self.livingroom = first_floor_east_living(mqtt_client, pd)
self.kitchen = first_floor_east_kitchen(mqtt_client)
self.livingroom = first_floor_east_living(mqtt_client)
self.sleep = first_floor_east_sleep(mqtt_client)
@ -40,62 +36,33 @@ class first_floor_east_floor(rooms.ffe_floor, room):
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
class first_floor_east_kitchen(room):
def __init__(self, mqtt_client, pd):
roo = props.ROO_KIT
#
# Device initialisation
#
# http://shelly1l-8CAAB5616C01
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light_hue = pd.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
# http://shelly1-e89f6d85a466
# circulation pump
self.circulation_pump_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_CIR)
# heating function
self.heating_valve = pd.get(props.STG_ZFE, loc, roo, props.FUN_HEA)
class first_floor_east_kitchen(rooms.ffe_kitchen, room):
def __init__(self, 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
#
# circulation pump
self.circulation_pump = timer_on_activation(self.circulation_pump_shelly, self.circulation_pump_shelly.KEY_OUTPUT_0, 10*60)
self.circulation_pump_shelly.add_callback(self.circulation_pump_shelly.KEY_OUTPUT_0, True, self.main_light_shelly.flash_0_mcb, True)
# Request hue data of lead light after power on
switched_light(self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0, self.main_light_hue)
switched_light(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0, self.light_main_light)
# circulation pump
self.circulation_pump = timer_on_activation(self.switch_circulation_pump, self.switch_circulation_pump.KEY_OUTPUT_0, 10*60)
self.switch_circulation_pump.add_callback(self.switch_circulation_pump.KEY_OUTPUT_0, True, self.switch_main_light.flash_0_mcb, True)
self.videv_circulation_pump.connect_sw_device(self.switch_circulation_pump, self.switch_circulation_pump.KEY_OUTPUT_0)
self.videv_circulation_pump.connect_tm_device(self.circulation_pump, timer_on_activation.KEY_TIMER)
# heating function
self.heating_function = heating_function(
self.heating_valve,
self.valve_heating,
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)
#
# Virtual Device Interface
#
# main light
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
self.main_light_hue, self.main_light_hue.KEY_BRIGHTNESS,
self.main_light_hue, self.main_light_hue.KEY_COLOR_TEMP
)
# circulation pump
self.circulation_pump_videv = videv_switching_timer(
mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_VIDEV,
self.circulation_pump_shelly, self.circulation_pump_shelly.KEY_OUTPUT_0,
self.circulation_pump, timer_on_activation.KEY_TIMER
)
# heating function
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_FFE_KITCHEN_HEATING_VALVE_VIDEV,
self.heating_function
)
self.videv_heating.connect_heating_function(self.heating_function)
class first_floor_east_dining(rooms.ffe_diningroom, room):
@ -128,10 +95,10 @@ class first_floor_east_dining(rooms.ffe_diningroom, room):
def __day_events__(self, device, key, data):
if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY):
if config.CHRISTMAS:
self.garland_powerplug.set_output_0(True)
self.switch_garland_light.set_output_0(True)
elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE):
if config.CHRISTMAS:
self.garland_powerplug.set_output_0(False)
self.switch_garland_light.set_output_0(False)
class first_floor_east_sleep(rooms.ffe_sleep, room):
@ -164,10 +131,7 @@ class first_floor_east_sleep(rooms.ffe_sleep, room):
self.input_device.add_callback(self.input_device.KEY_ACTION, self.input_device.ACTION_LEFT_LONG,
self.switch_bed_marion_light.toggle_output_0_mcb)
# button
self.brightness_functions_device_videv = videv_multistate(
mqtt_client, config.TOPIC_FFE_SLEEP_ACTIVE_BRIGHTNESS_DEVICE_VIDEV,
brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 2
)
self.videv_multistate.connect_br_function(self.brightness_functions, brightness_choose_n_action.KEY_ACTIVE_DEVICE, 2)
# heating function
self.heating_function = heating_function(
@ -179,65 +143,31 @@ class first_floor_east_sleep(rooms.ffe_sleep, room):
self.videv_heating.connect_heating_function(self.heating_function)
class first_floor_east_living(room):
def __init__(self, mqtt_client, pd):
roo = props.ROO_LIV
#
# Device initialisation
#
# http://shelly1l-3C6105E3F910
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light_tradfri = pd.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
# floor lamp
self.floorlamp_tradfri = pd.get(props.STG_ZFE, loc, roo, props.FUN_FLL)
# heating function
self.heating_valve = pd.get(props.STG_ZFE, loc, roo, props.FUN_HEA)
# xmas tree
if config.CHRISTMAS:
self.powerplug_xmas_tree = pd.get(props.STG_ZFE, loc, roo, props.FUN_XTR)
self.powerplug_xmas_star = pd.get(props.STG_ZFE, loc, roo, props.FUN_XST)
class first_floor_east_living(rooms.ffe_livingroom, room):
def __init__(self, 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)
#
self.videv_floor_light.connect_sw_device(self.light_floor_light, self.light_floor_light.KEY_OUTPUT_0)
self.videv_floor_light.connect_br_device(self.light_floor_light, self.light_floor_light.KEY_BRIGHTNESS)
self.videv_floor_light.connect_ct_device(self.light_floor_light, self.light_floor_light.KEY_COLOR_TEMP)
#
if config.CHRISTMAS:
self.videv_xmas_tree_light.connect_sw_device(self.switch_xmas_tree_light, self.switch_xmas_tree_light.KEY_OUTPUT_0)
# main light -> floor_light
self.switch_main_light.add_callback(self.switch_main_light.KEY_OUTPUT_0, None, self.light_floor_light.set_output_0_mcb, True)
#
# Functionality initialisation
#
# floor lamp synchronisation with main_light
self.main_light_shelly.add_callback(self.main_light_shelly.KEY_OUTPUT_0, None, self.floorlamp_tradfri.set_output_0_mcb, True)
# heating function
self.heating_function = heating_function(
self.heating_valve,
self.valve_heating,
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)
#
# Virtual Device Interface
#
# main light
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFE_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
)
# floor lamp
self.floorlamp_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_VIDEV,
self.floorlamp_tradfri, self.floorlamp_tradfri.KEY_OUTPUT_0,
self.floorlamp_tradfri, self.floorlamp_tradfri.KEY_BRIGHTNESS,
self.floorlamp_tradfri, self.floorlamp_tradfri.KEY_COLOR_TEMP
)
# heating function
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_FFE_LIVINGROOM_HEATING_VALVE_VIDEV,
self.heating_function
)
# xmas tree
if config.CHRISTMAS:
self.xmas_tree_videv = videv_switching(
mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV,
self.powerplug_xmas_tree, self.powerplug_xmas_tree.KEY_OUTPUT_0
)
self.videv_heating.connect_heating_function(self.heating_function)

View File

@ -47,13 +47,16 @@ class videv_switching(videv_base):
self.add_routing(self.KEY_STATE, sw_device, sw_key)
class videv_switching_timer(videv_base):
KEY_STATE = 'state'
class videv_switching_timer(videv_switching):
KEY_TIMER = 'timer'
def __init__(self, mqtt_client, topic, sw_device, sw_key, tm_device, tm_key):
super().__init__(mqtt_client, topic)
self.add_routing(self.KEY_STATE, sw_device, sw_key)
def __init__(self, mqtt_client, topic, sw_device=None, sw_key=None, tm_device=None, tm_key=None):
super().__init__(mqtt_client, topic, sw_device, sw_key)
# TODO: Remove the following code and the parameters from __init__
if tm_device is not None and tm_key is not None:
self.connect_tm_device(tm_device, tm_key)
def connect_tm_device(self, tm_device, tm_key):
self.add_display(self.KEY_TIMER, tm_device, tm_key)
@ -134,8 +137,13 @@ class videv_heating(videv_base):
class videv_multistate(videv_base):
KEY_STATE = 'state_%d'
def __init__(self, mqtt_client, topic, key_for_device, device, num_states, default_values=None):
def __init__(self, mqtt_client, topic, key_for_device=None, device=None, num_states=None, default_values=None):
super().__init__(mqtt_client, topic)
# TODO: Remove the following code and the parameters from __init__
if device is not None and key_for_device is not None and num_states is not None:
self.connect_br_function(device, key_for_device, num_states)
def connect_br_function(self, device, key_for_device, num_states):
self.num_states = num_states
# send default values
for i in range(0, num_states):