2023-08-03 20:43:41 +02:00
|
|
|
import config
|
2023-10-22 20:13:18 +02:00
|
|
|
import devdi
|
|
|
|
import devdi.props as props
|
|
|
|
#import function
|
|
|
|
#import json
|
2023-08-03 20:43:41 +02:00
|
|
|
import logging
|
|
|
|
import mqtt
|
2023-10-22 20:13:18 +02:00
|
|
|
import os
|
2023-08-03 20:43:41 +02:00
|
|
|
import report
|
2023-10-22 20:13:18 +02:00
|
|
|
#import subprocess
|
2023-08-03 20:43:41 +02:00
|
|
|
import time
|
|
|
|
|
2023-10-22 20:13:18 +02:00
|
|
|
logger = logging.getLogger(config.APP_NAME)
|
2023-08-03 20:43:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-10-22 20:13:18 +02:00
|
|
|
#
|
|
|
|
# Logging
|
|
|
|
#
|
|
|
|
if config.DEBUG:
|
|
|
|
report.appLoggingConfigure(None, 'stdout', ((config.APP_NAME, logging.DEBUG), ),
|
|
|
|
target_level=logging.WARNING, fmt=report.SHORT_FMT, host='localhost', port=19996)
|
|
|
|
else:
|
|
|
|
report.stdoutLoggingConfigure(((config.APP_NAME, logging.WARNING), ), report.SHORT_FMT)
|
|
|
|
|
|
|
|
#
|
|
|
|
# MQTT Client
|
|
|
|
#
|
2023-08-03 20:43:41 +02:00
|
|
|
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
2023-10-22 20:13:18 +02:00
|
|
|
password=config.MQTT_PASSWORD, name=config.APP_NAME)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Smarthome Devices
|
|
|
|
#
|
|
|
|
ddi = devdi.devices(mc)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Smart Home Functionality
|
|
|
|
#
|
|
|
|
#######
|
|
|
|
# GFW #
|
|
|
|
#######
|
|
|
|
loc = props.LOC_GFW
|
|
|
|
# DIRK
|
|
|
|
roo = props.ROO_DIR
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
|
|
|
tml = ddi.get(props.STG_ZGW, loc, roo, props.FUN_MAL)
|
|
|
|
sml.register_power_on_instance(tml)
|
|
|
|
# FLOOR
|
|
|
|
roo = props.ROO_FLO
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
|
|
|
tml = ddi.get(props.STG_ZGW, loc, roo, props.FUN_MAL, 1)
|
|
|
|
sml.register_power_on_instance(tml)
|
|
|
|
tml = ddi.get(props.STG_ZGW, loc, roo, props.FUN_MAL, 2)
|
|
|
|
sml.register_power_on_instance(tml)
|
|
|
|
|
|
|
|
#######
|
|
|
|
# FFW #
|
|
|
|
#######
|
|
|
|
loc = props.LOC_FFW
|
|
|
|
# JULIAN
|
|
|
|
roo = props.ROO_JUL
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
|
|
|
tml = ddi.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
|
|
|
|
sml.register_power_on_instance(tml)
|
|
|
|
# LIVINGROOM
|
|
|
|
roo = props.ROO_LIV
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
|
|
|
tml = ddi.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
|
|
|
|
sml.register_power_on_instance(tml)
|
|
|
|
# SLEEP
|
|
|
|
roo = props.ROO_SLP
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
|
|
|
tml = ddi.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
|
|
|
|
sml.register_power_on_instance(tml)
|
|
|
|
|
|
|
|
#######
|
|
|
|
# FFE #
|
|
|
|
#######
|
|
|
|
loc = props.LOC_FFE
|
2023-10-22 20:41:51 +02:00
|
|
|
# KITCHEN
|
|
|
|
roo = props.ROO_KIT
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_CIR)
|
|
|
|
sml.auto_off(600)
|
2023-10-22 20:13:18 +02:00
|
|
|
# LIVINGROOM
|
|
|
|
roo = props.ROO_LIV
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
|
|
|
tml = ddi.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
|
|
|
|
sml.register_power_on_instance(tml)
|
|
|
|
# SLEEP
|
|
|
|
roo = props.ROO_SLP
|
|
|
|
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
|
|
|
tml = ddi.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
|
|
|
|
sml.register_power_on_instance(tml)
|
2023-08-03 20:43:41 +02:00
|
|
|
|
|
|
|
while (True):
|
|
|
|
time.sleep(1)
|