Module update + adaptions due to module update
This commit is contained in:
parent
1159fd691b
commit
cdedc126eb
@ -1 +1 @@
|
|||||||
Subproject commit 8ab382dd63bd8b8f3819bebf5be4a3089abbeaff
|
Subproject commit 877ba5a47b605067e134ad7c51c378f14dc76a35
|
@ -1 +1 @@
|
|||||||
Subproject commit e1f76d96312e540544b2328d0937b0aa41126aa9
|
Subproject commit 6142649b3de313f2a1ef65441ae14423c0cf8cd0
|
2
task
2
task
@ -1 +1 @@
|
|||||||
Subproject commit af35e83d1f07fd4cb9070bdb77cf1f3bdda3a463
|
Subproject commit bb6f7ea26f24481cba7218256e47572fa84db478
|
@ -1 +1 @@
|
|||||||
Subproject commit ffe6b2bf3ba5829361349ff318cb721cb6f42266
|
Subproject commit c7aced7c3f708e81ccbb17163267f96642dd5381
|
0
z_server/.venv_required
Normal file
0
z_server/.venv_required
Normal file
133
z_server/Makefile
Normal file
133
z_server/Makefile
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
# git helper Makefile: Version 2.5 (2025-08-11)
|
||||||
|
default: help
|
||||||
|
|
||||||
|
.ONESHELL:
|
||||||
|
SHELL = /usr/bin/bash
|
||||||
|
MAKEFLAGS += --no-print-directory
|
||||||
|
.SILENT:
|
||||||
|
|
||||||
|
-include __make.d__/*.mk
|
||||||
|
|
||||||
|
GIT_FLAG = ./.git
|
||||||
|
VENV_FLAG = ./.venv_required
|
||||||
|
VENV_FOLDER = ./venv
|
||||||
|
|
||||||
|
localhelp:
|
||||||
|
|
||||||
|
help:
|
||||||
|
echo "Possible common options are:"
|
||||||
|
echo " - init - Initialise the repository and all folders below with a Makefile"
|
||||||
|
echo " - giti - Get the git status of all submodules including their submodules"
|
||||||
|
echo " - update_submodules - Set all submodules to remote master"
|
||||||
|
echo " - venv_flag - Set the venev flag for the base folder. A venv will be generated"
|
||||||
|
echo " - clean - clean up"
|
||||||
|
echo " - deepclean - clean up this and all Makefiles below"
|
||||||
|
$(MAKE) localhelp
|
||||||
|
echo "You are able to create files make.d/*.mk and add local rules there. "
|
||||||
|
echo " - localinit: print_head - Will be executed as last step in the init process."
|
||||||
|
echo " - localhelp: print_head - Will be executed in th middle of the help text generation"
|
||||||
|
echo " - localclean:print_head - Will be executed before the clean rule"
|
||||||
|
|
||||||
|
localinit:
|
||||||
|
|
||||||
|
init: print_head
|
||||||
|
# Init git repo
|
||||||
|
if [[ -e $(GIT_FLAG) ]]; then
|
||||||
|
echo -e "\033[1;33mInitialising git submodules...\e[0m"
|
||||||
|
git submodule init
|
||||||
|
git submodule update
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
# Init submodules
|
||||||
|
SUBDIRS=$$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort)
|
||||||
|
for subdir in $$SUBDIRS; do
|
||||||
|
$(MAKE) --no-print-directory -C $$(dirname $$subdir) init
|
||||||
|
done
|
||||||
|
if [[ $$SUBDIRS = *[![:space:]]* ]]; then
|
||||||
|
$(MAKE) print_head
|
||||||
|
fi
|
||||||
|
# Create venv if needed
|
||||||
|
if [[ -e $(VENV_FLAG) ]]; then
|
||||||
|
BASEPATH=$$(pwd -P)
|
||||||
|
#
|
||||||
|
# Create venv
|
||||||
|
#
|
||||||
|
if [ ! -e venv ];then
|
||||||
|
echo -e "\033[1;33mCreating venv in $$BASEPATH...\e[0m"
|
||||||
|
python3 -m venv $$BASEPATH/venv > /dev/null 2>&1
|
||||||
|
else
|
||||||
|
echo -e "\033[1;33mVirtualenv already exists in $$BASEPATH...\e[0m"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install modules
|
||||||
|
#
|
||||||
|
echo -e "\033[1;33mInstalling modules to venv in $$BASEPATH...\e[0m"
|
||||||
|
for req_file in $$(find -L $$BASEPATH -name requirements.txt 2> /dev/null); do
|
||||||
|
# echo " $$req_file"
|
||||||
|
while read req_mod; do
|
||||||
|
if [[ $$req_mod = *[![:space:]]* ]]; then
|
||||||
|
# req_mod is not empty
|
||||||
|
OUT=$$($$BASEPATH/venv/bin/pip install -U $$req_mod 2>&1 )
|
||||||
|
if [[ $$OUT =~ "Successfully installed" ]]; then
|
||||||
|
echo -e " * \033[1;32m$$req_mod installed.\e[0m"
|
||||||
|
elif [[ $$OUT =~ "already satisfied" ]]; then
|
||||||
|
echo -e " * \033[1;36m$$req_mod already installed.\e[0m"
|
||||||
|
else
|
||||||
|
echo -e " * \033[1;31m$$req_mod installation FAILED!\e[0m"
|
||||||
|
#echo $$OUT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < $$req_file
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
# Start local init
|
||||||
|
echo -e "\033[1;33mDoing localinit...\e[0m"
|
||||||
|
$(MAKE) localinit
|
||||||
|
|
||||||
|
update_submodules:
|
||||||
|
git submodule foreach "git fetch && git checkout master && git pull && git submodule init && git submodule update"
|
||||||
|
|
||||||
|
giti_this: print_head
|
||||||
|
giti
|
||||||
|
echo " Submodules:"
|
||||||
|
git submodule --quiet foreach "echo -n ' ' && giti"
|
||||||
|
|
||||||
|
giti:
|
||||||
|
git submodule --quiet foreach "[ -e Makefile ] && make --no-print-directory giti_this || :"
|
||||||
|
|
||||||
|
localclean:
|
||||||
|
|
||||||
|
clean: localclean
|
||||||
|
if [[ ! -e $(VENV_FLAG) ]]; then
|
||||||
|
if [[ -d $(VENV_FOLDER) ]]; then
|
||||||
|
rm -rf $(VENV_FOLDER)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cleanall: clean
|
||||||
|
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
|
||||||
|
$(MAKE) --no-print-directory -C $$(dirname $$subdir) cleanall
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
venv_flag:
|
||||||
|
if [[ ! -e $(VENV_FLAG) ]]; then
|
||||||
|
touch $(VENV_FLAG)
|
||||||
|
if [[ -e $(GIT_FLAG) ]]; then
|
||||||
|
git add $(VENV_FLAG)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_head:
|
||||||
|
DIRNAME=$$(basename $$(pwd))
|
||||||
|
DIRLENGTH=$${#DIRNAME}
|
||||||
|
echo -ne "\n\n\033[1;34m╔═"
|
||||||
|
for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done
|
||||||
|
echo -e "═╗"
|
||||||
|
echo -e "║ $$DIRNAME ║"
|
||||||
|
echo -ne "╚═"
|
||||||
|
for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done
|
||||||
|
echo -e "═╝\033[00m"
|
@ -1,9 +1,15 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
DEBUG = False # False: logging to stdout with given LOGLEVEL - True: logging all to localhost:19996 and warnings or higher to stdout
|
DEBUG = False
|
||||||
LOGLEVEL = logging.INFO
|
#
|
||||||
|
# Logging
|
||||||
|
#
|
||||||
APP_NAME = "z_monitor"
|
APP_NAME = "z_monitor"
|
||||||
|
LOG_HOSTNAME = "localhost" # When DEBUG is True
|
||||||
|
LOG_LEVEL = logging.INFO # STDOUT logging
|
||||||
|
|
||||||
|
CHRISTMAS = False
|
||||||
|
|
||||||
|
|
||||||
MQTT_SERVER = "{{ server_nagios_hostname }}"
|
MQTT_SERVER = "{{ server_nagios_hostname }}"
|
||||||
MQTT_PORT = 1883
|
MQTT_PORT = 1883
|
||||||
@ -11,3 +17,4 @@ MQTT_USER = "{{ server_nagios_username }}"
|
|||||||
MQTT_PASSWORD = "{{ server_nagios_password }}"
|
MQTT_PASSWORD = "{{ server_nagios_password }}"
|
||||||
|
|
||||||
SOCK_PROT_PORT = 8380
|
SOCK_PROT_PORT = 8380
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8f8ace13c131abf9c4dfb79087fa1c13c76805d2
|
Subproject commit 5a5679b0baa9ba978f75d8581cb0dc7c13158e34
|
@ -68,6 +68,9 @@ class base(object):
|
|||||||
if message.topic == self.topic:
|
if message.topic == self.topic:
|
||||||
self.last_device_msg = time.time()
|
self.last_device_msg = time.time()
|
||||||
|
|
||||||
|
def set_ch_name(self, key, name):
|
||||||
|
pass
|
||||||
|
|
||||||
def target(self, key, value):
|
def target(self, key, value):
|
||||||
tm_t, value_t = self.__target_storage__.get(key, (0, None))
|
tm_t, value_t = self.__target_storage__.get(key, (0, None))
|
||||||
if value != value_t:
|
if value != value_t:
|
||||||
@ -188,6 +191,10 @@ class tradfri_sw_br_ct(base):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class hue_sw_br_ct(base):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class tradfri_button(base):
|
class tradfri_button(base):
|
||||||
LAST_MSG_WARNING = 24 * 60 * 60
|
LAST_MSG_WARNING = 24 * 60 * 60
|
||||||
LAST_MSG_ERROR = 48 * 60 * 60
|
LAST_MSG_ERROR = 48 * 60 * 60
|
||||||
@ -238,7 +245,10 @@ class silvercrest_motion_sensor(base):
|
|||||||
|
|
||||||
|
|
||||||
class my_powerplug(base):
|
class my_powerplug(base):
|
||||||
pass
|
KEY_OUTPUT_0 = None
|
||||||
|
KEY_OUTPUT_1 = None
|
||||||
|
KEY_OUTPUT_2 = None
|
||||||
|
KEY_OUTPUT_3 = None
|
||||||
|
|
||||||
|
|
||||||
class audio_status(base):
|
class audio_status(base):
|
||||||
@ -301,3 +311,24 @@ class my_ambient(base):
|
|||||||
return self.__nagios_return__(DID_HEARTBEAT, status, msg)
|
return self.__nagios_return__(DID_HEARTBEAT, status, msg)
|
||||||
else:
|
else:
|
||||||
return super().status(key)
|
return super().status(key)
|
||||||
|
|
||||||
|
class videv_sw(base):
|
||||||
|
pass
|
||||||
|
class videv_sw_br(base):
|
||||||
|
pass
|
||||||
|
class videv_sw_br_ct(base):
|
||||||
|
pass
|
||||||
|
class videv_sw_tm(base):
|
||||||
|
pass
|
||||||
|
class videv_sw_mo(base):
|
||||||
|
pass
|
||||||
|
class videv_hea(base):
|
||||||
|
pass
|
||||||
|
class videv_pure_switch(base):
|
||||||
|
pass
|
||||||
|
class videv_multistate(base):
|
||||||
|
pass
|
||||||
|
class videv_audio_player(base):
|
||||||
|
pass
|
||||||
|
class videv_all_off(base):
|
||||||
|
pass
|
@ -1 +1 @@
|
|||||||
Subproject commit 14e56ccdbf6594f699b4afcfb4acafe9b899e914
|
Subproject commit c2b32852127bc1a3aca078a2dad3993f46cb81c2
|
@ -1 +1 @@
|
|||||||
Subproject commit 7003c13ef8c7e7c3a55a545cbbad4039cc024a9f
|
Subproject commit 152690007a3b87ee0047bcad78b2673111ff1928
|
@ -1,26 +1,48 @@
|
|||||||
import config
|
import config
|
||||||
import devdi.devices as devices
|
import devdi.rooms as rooms
|
||||||
import logging
|
import devdi.topic
|
||||||
import mqtt
|
import mqtt
|
||||||
import report
|
import report
|
||||||
import z_protocol
|
import z_protocol
|
||||||
import socket_protocol
|
|
||||||
import tcp_socket
|
import tcp_socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
logger = logging.getLogger(config.APP_NAME)
|
logger = report.default_logging_config()
|
||||||
|
|
||||||
|
|
||||||
|
class devices(dict):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
def __key_by_value__(self, dictionary, value):
|
||||||
|
for key in dictionary:
|
||||||
|
if dictionary[key] == value:
|
||||||
|
return key
|
||||||
|
|
||||||
|
def add_room(self, room):
|
||||||
|
for key, value in room.__dict__.items():
|
||||||
|
inst = getattr(room, key)
|
||||||
|
try:
|
||||||
|
topic = inst.topic
|
||||||
|
except AttributeError:
|
||||||
|
pass # attribute is nor device
|
||||||
|
else:
|
||||||
|
STG, LOC, ROO, FUN = topic.split("/")[:4]
|
||||||
|
STG = self.__key_by_value__(devdi.topic.STG_TOPIC, STG)
|
||||||
|
LOC = self.__key_by_value__(devdi.topic.LOC_TOPIC, LOC)
|
||||||
|
ROO = self.__key_by_value__(devdi.topic.ROO_TOPIC, ROO)
|
||||||
|
FUN = self.__key_by_value__(devdi.topic.FUN_TOPIC, FUN)
|
||||||
|
self[f"{STG}.{LOC}.{ROO}.{FUN}"] = inst
|
||||||
|
|
||||||
|
def get_str(self, **kwargs):
|
||||||
|
STG = getattr(devdi.topic, kwargs.get("stg"))
|
||||||
|
LOC = getattr(devdi.topic, kwargs.get("loc"))
|
||||||
|
ROO = getattr(devdi.topic, kwargs.get("roo"))
|
||||||
|
FUN = getattr(devdi.topic, kwargs.get("fun"))
|
||||||
|
return self.get(f"{STG}.{LOC}.{ROO}.{FUN}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#
|
|
||||||
# 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, config.LOGLEVEL), ), report.SHORT_FMT)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# MQTT Client
|
# MQTT Client
|
||||||
#
|
#
|
||||||
@ -29,7 +51,22 @@ if __name__ == "__main__":
|
|||||||
#
|
#
|
||||||
# Smarthome physical Devices
|
# Smarthome physical Devices
|
||||||
#
|
#
|
||||||
pd = devices.physical_devices(mc)
|
pd = devices()
|
||||||
|
pd.add_room(rooms.ffe_diningroom(mc))
|
||||||
|
pd.add_room(rooms.ffe_floor(mc))
|
||||||
|
pd.add_room(rooms.ffe_kitchen(mc))
|
||||||
|
pd.add_room(rooms.ffe_livingroom(mc))
|
||||||
|
pd.add_room(rooms.ffe_sleep(mc))
|
||||||
|
pd.add_room(rooms.ffw_bath(mc))
|
||||||
|
pd.add_room(rooms.ffw_floor(mc))
|
||||||
|
pd.add_room(rooms.ffw_julian(mc))
|
||||||
|
pd.add_room(rooms.ffw_livingroom(mc))
|
||||||
|
pd.add_room(rooms.ffw_sleep(mc))
|
||||||
|
pd.add_room(rooms.gar_garden(mc))
|
||||||
|
pd.add_room(rooms.gfw_dirk(mc))
|
||||||
|
pd.add_room(rooms.gfw_floor(mc))
|
||||||
|
pd.add_room(rooms.gfw_marion(mc))
|
||||||
|
pd.add_room(rooms.stairway(mc))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Socket Protocol
|
# Socket Protocol
|
||||||
|
Loading…
x
Reference in New Issue
Block a user