From 5255f319f1ee96efd28d784029a5450a92bac183 Mon Sep 17 00:00:00 2001 From: Borzutzki Robert Date: Mon, 25 Nov 2024 22:07:51 +0100 Subject: [PATCH] first change --- .DS_Store | Bin 0 -> 8196 bytes examples/solar-monitoring.py | 80 +++++++---------------------------- 2 files changed, 16 insertions(+), 64 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d1a63b56e781d6e9309a4c597d5a297b70a088e6 GIT binary patch literal 8196 zcmeHMTZ|M%6s^;{KsVd4y)eK!vdqA!L>OUt4Im)1FLZfsc6QkZ$S^bALWkb&VY+7) zUD5UNqlEa1h8Xo%3Cf32gOBKkLD3IC6dxGlhf!mEe;B{~@K#q3u)FYQqGr32s@wP8 zy47`Wom-u%W{jb=tgm3KkufGy2_^A~RVbKYaQ5-7;OTx%o3lHMLWwPLrp}b@J_*gU)cq%XwwD zHCNihxgN){^3~^Dez$21XSGP1V|zK%HcGyMsTWpYl@9sWzAgj%)(6o0IJ=3w>-A2hJn$_xEa<8-C*j*)q z>-!3hRUWe4tkzJ-S%tEd^NbeD%9wW>Aw$jb&Dhb{f&`H|dq!Ffz_HD5q!6o4@e-CCgW@-_*Kg>(2A_TEi?gqR#EB zn68<(jNV~W_YMx^+=5~2rhQY_v$o}9gfZ|bzc)*5WP;8_i%Yz$)Hw<)y2^p6)h+CxHMleL{eR* zXs*(8h!$Izu25IWny&O(xx8TsQA%AWYul8*iioukM%0b6(qC|fhG^2RkZq2($l5u1 zAAj-ooa^l>8g_L`o1-1FJm?f66qykH4@cD@nfkZ(#?TDW=(7*YiHZp zepX^5>^M8YPO(?mS@s_Llzq*5wLqRD8f*-dO2NgRbo$Dv z6ub4d&aLY9|4k}gn8}l8c4W@nd2yam>o&Dqgq}cZ6`YrY-pBcv?C^2!V_`f-DaEdx z-=xNRDG`h#<5RPmvf4DBnDTkvd*LEArcI$#5$p|%iJeMmBG{$LSWJ^BI|bXkBBp9J zlzWPAyCz920%rZqs;bpe77E=hO~kT*X>FrncuvXx6uK|4Z`cp)clH;ddnRV15sT4` z6gCo;ccKd!^q`mUydQZKd`vrp=n`Dqje7{y_Ytm-;W!?_qj(HY;~6~bWBVjd;YGZJ z*Kh`};|;uvvv?op@Bu!=C-@5A;Ya*54#PXfVi8!_Z$izOivZ#;{xGEH eICbSV>41(3N)jsn!bJd-@cSQr|9$jL-sW#NH&0yv literal 0 HcmV?d00001 diff --git a/examples/solar-monitoring.py b/examples/solar-monitoring.py index 7ce0689..4cc754e 100644 --- a/examples/solar-monitoring.py +++ b/examples/solar-monitoring.py @@ -14,56 +14,11 @@ import time from PIL import Image,ImageDraw,ImageFont import traceback -# Import MQTT client. -from paho.mqtt import client as mqtt_client logging.basicConfig(level=logging.DEBUG) -# MQTT credentials -#mqtt_username = 'homeassistant' # MQTT client username -#mqtt_password = '3355' # MQTT client password -client_id = 'solarmonitor' # unique client_id -mqtt_broker = "openwb-2" # broker address, usually your HASS IP address -port = 1883 -#set topics -topic0 = { - "topic" : "openWB/bat/get/soc", - "line" : "0", - "value" : "" -} -topic1 = { - "topic" : "openWB/bat/get/power", - "line" : "16", - "value" : "" -} -topic2 = { - "topic" : "openWB/counter/7/get/power", - "line" : "32", - "value" : "" -} -topic3 = { - "topic" : "openWB/pv/8/get/power", - "line" : "48", - "value" : "" -} -topic4 = { - "topic" : "openWB/graph/lastlivevaluesJson", #house-power - "line" : "64", - "value" : "" -} -topic5 = { - "topic" : "openWB/vehicle/4/get/soc", - "line" : "80", - "value" : "" -} -topic6 = { - "topic" : "openWB/internal_chargepoint/0/get/powers", - "line" : "80", - "value" : "" -} -topics = {0:topic0,1:topic1,2:topic2,3:topic3,4:topic4,5:topic5,6:topic6} #Define Display epd = epd2in13b_V3.EPD() @@ -79,28 +34,25 @@ HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red drawblack = ImageDraw.Draw(HBlackimage) #drawry = ImageDraw.Draw(HRYimage) -def connect_mqtt(): - def on_connect(client, userdata, flags, rc): - if rc == 0: - logging.info("Connected to MQTT Broker!") - else: - logging.info("Failed to connect, return code %d\n", rc) +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- - client = mqtt_client.Client(client_id) - # client.username_pw_set(username, password) - client.on_connect = on_connect - client.connect(mqtt_broker, port) - return client +import time +import datetime +import locale +loc = locale.getlocale() +print (loc) -def subscribe(client: mqtt_client, topic): - def on_message(client, userdata, msg): - print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic") - - client.loop_start() - client.subscribe(topic) - client.on_message = on_message - client.loop_stop() +datum = input('Datum: ') +td = datetime.timedelta(int(input('Abstand: '))) +datum1 = time.strptime(datum, '%Y-%m-%d') +datum2 = (datetime.datetime.fromtimestamp(time.mktime(datum1)) - td) +print(datum2.strftime('%Y-%m-%d')) + +print(datum2.strftime('Der Wochentag ist %A')) +locale.setlocale(locale.LC_ALL, ('de_DE', 'UTF-8')) +print(datum2.strftime('Der Wochentag ist %A')) def init_monitor(topics):