first version working with handle of projector sutdown, collect some data about current show
This commit is contained in:
+27
-27
@@ -144,33 +144,33 @@ services:
|
||||
# - 6789:6789 #optional
|
||||
# - 5514:5514/udp #optional
|
||||
|
||||
projmon:
|
||||
build:
|
||||
context: ../projmon
|
||||
dockerfile: ../projmon/projmon.Dockerfile
|
||||
args:
|
||||
BUILD_VER:
|
||||
container_name: edx-projmon
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- influxdb3
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "5"
|
||||
environment:
|
||||
- INTERVAL=15
|
||||
- PROJECTOR_IP=192.168.31.10
|
||||
- PROJECTOR_USER=alberto
|
||||
- PROJECTOR_PASSWORD=alberto
|
||||
- MQTT_USER=projmon
|
||||
- MQTT_PASSWORD=projmon
|
||||
- MQTT_HOST=192.168.31.26
|
||||
- MQTT_PORT=1883
|
||||
- LOG_FILE=/tmp/projmon.log
|
||||
- LOG_FILE_LVL=WARNING
|
||||
- LOG_CLI_LVL=INFO
|
||||
projmon:
|
||||
build:
|
||||
context: ../projmon
|
||||
dockerfile: ../projmon/projmon.Dockerfile
|
||||
args:
|
||||
BUILD_VER:
|
||||
container_name: edx-projmon
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- influxdb3
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "5"
|
||||
environment:
|
||||
- INTERVAL=15
|
||||
- PROJECTOR_IP=192.168.31.10
|
||||
- PROJECTOR_USER=alberto
|
||||
- PROJECTOR_PASSWORD=alberto
|
||||
- MQTT_USER=projmon
|
||||
- MQTT_PASSWORD=projmon
|
||||
- MQTT_HOST=192.168.31.26
|
||||
- MQTT_PORT=1883
|
||||
- LOG_FILE=/tmp/projmon.log
|
||||
- LOG_FILE_LVL=WARNING
|
||||
- LOG_CLI_LVL=INFO
|
||||
|
||||
volumes:
|
||||
grafana-data:
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
HA_CONFIG_TEMPLATE = {
|
||||
"name": "{device_friendly_name}",
|
||||
"state_topic": "{device_name}/state",
|
||||
"unique_id": "{device_name}_{device_state}",
|
||||
"icon": "{device_icon}",
|
||||
"device": {
|
||||
"identifiers": ["{device_name}"],
|
||||
"name": "{device_friendly_name}",
|
||||
"manufacturer": "ETSS",
|
||||
"model": "Edelweiss_Automation"
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ ARG BUILD_VER
|
||||
|
||||
RUN apk update && apk upgrade --no-cache
|
||||
|
||||
RUN pip install --no-cache-dir influxdb3-python xmltodict requests
|
||||
RUN pip install --no-cache-dir xmltodict requests pydantic paho-mqtt influxdb3-python
|
||||
|
||||
COPY ./projmon.py /home/projmon.py
|
||||
COPY ./*.py /home/
|
||||
COPY ./utils.py /home/pyutils/utils.py
|
||||
|
||||
ENV VER=${BUILD_VER}
|
||||
|
||||
+4
-4
@@ -11,8 +11,8 @@ from commands import ShowStatus, SMSMessage, SPLList, SPLMetadata, StorageInfo
|
||||
from paho.mqtt import client as mqtt_client
|
||||
from paho.mqtt.enums import CallbackAPIVersion
|
||||
from pydantic import BaseModel, Field
|
||||
from requests import Timeout
|
||||
from utils import SignalHandler
|
||||
from requests import Timeout, ConnectionError
|
||||
from pyutils.utils import SignalHandler
|
||||
|
||||
T = TypeVar("T", bound=SMSMessage)
|
||||
|
||||
@@ -222,8 +222,8 @@ def main() -> int:
|
||||
exclude_unset=True),
|
||||
retain=True)
|
||||
break
|
||||
except Timeout as te:
|
||||
LOGGER.debug("Projector is probably shutdown: %s", te)
|
||||
except (Timeout, ConnectionError) as ce:
|
||||
LOGGER.debug("Projector is probably shutdown: %s", ce)
|
||||
except Exception as e:
|
||||
LOGGER.error("Unexpected exception: [%s]", e)
|
||||
return 1
|
||||
|
||||
@@ -35,7 +35,7 @@ class ProjectorConnection():
|
||||
},
|
||||
auth=self.auth,
|
||||
allow_redirects=False,
|
||||
timeout=4,
|
||||
timeout=5,
|
||||
verify=False
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import signal
|
||||
from logging import Logger
|
||||
from influxdb_client_3 import Point
|
||||
|
||||
class SignalHandler:
|
||||
running: bool
|
||||
logger: Logger
|
||||
|
||||
def __init__(self, logger):
|
||||
self.running: bool = True
|
||||
self.logger: Logger = logger
|
||||
signal.signal(signal.SIGINT, self._handle_sigint)
|
||||
signal.signal(signal.SIGTERM, self._handle_sigint)
|
||||
|
||||
def _handle_sigint(self, signum, frame):
|
||||
self.logger.info(f"Received SIGNAL: {signal.strsignal(signum)}")
|
||||
self.running = False
|
||||
|
||||
def dict2Point(measurement: str, fields: dict, tags: dict | None = None) -> Point:
|
||||
p = Point(measurement)
|
||||
for k,v in fields.items():
|
||||
p.field(k,v)
|
||||
if tags:
|
||||
for k,v in tags.items():
|
||||
p.tag(k,v)
|
||||
return p
|
||||
|
||||
def convertInt(d: dict) -> dict:
|
||||
for k,v in d.items():
|
||||
if str.isdecimal(v):
|
||||
d[k] = int(v)
|
||||
return d
|
||||
|
||||
def convertIntList(l: list[dict]) -> list[dict]:
|
||||
for n,d in enumerate(l):
|
||||
l[n] = convertInt(d)
|
||||
return l
|
||||
Reference in New Issue
Block a user