move connect into try
This commit is contained in:
parent
d0928855d1
commit
0103569345
@ -25,13 +25,7 @@ logging.basicConfig(level=logging.DEBUG)
|
|||||||
client_id = 'solarmonitor' # unique client_id
|
client_id = 'solarmonitor' # unique client_id
|
||||||
mqtt_broker = "openwb-2" # broker address, usually your HASS IP address
|
mqtt_broker = "openwb-2" # broker address, usually your HASS IP address
|
||||||
|
|
||||||
# create the MQTT client
|
#set topics
|
||||||
client = mqtt_client.Client(client_id, protocol=mqtt_client.MQTTv31) # * set a random string (max 23 chars)
|
|
||||||
|
|
||||||
# client connection
|
|
||||||
# client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
|
||||||
client.connect(mqtt_broker, 1883, 60) # MQTT server address
|
|
||||||
|
|
||||||
topic_house_battery_soc = "openWB/bat/get/soc"
|
topic_house_battery_soc = "openWB/bat/get/soc"
|
||||||
topic_house_battery_power = "openWB/bat/get/power"
|
topic_house_battery_power = "openWB/bat/get/power"
|
||||||
|
|
||||||
@ -44,15 +38,23 @@ topic_car_soc = "openWB/vehicle/4/get/soc"
|
|||||||
topic_charge_point_power = "openWB/internal_chargepoint/0/get/powers"
|
topic_charge_point_power = "openWB/internal_chargepoint/0/get/powers"
|
||||||
|
|
||||||
|
|
||||||
house_battery_soc = client.subscribe(topic_house_battery_soc)
|
|
||||||
house_battery_power = client.subscribe(topic_house_battery_power)
|
|
||||||
power_import_export = client.subscribe(topic_power_import_export)
|
|
||||||
pv_power = client.subscribe(topic_pv_power)
|
|
||||||
house_power = client.subscribe(topic_house_power)
|
|
||||||
car_soc = client.subscribe(topic_car_soc)
|
|
||||||
charge_point_power = client.subscribe(topic_charge_point_power)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# create the MQTT client
|
||||||
|
client = mqtt_client.Client(client_id, protocol=mqtt_client.MQTTv31) # * set a random string (max 23 chars)
|
||||||
|
|
||||||
|
# client connection
|
||||||
|
# client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
||||||
|
client.connect(mqtt_broker, 1883, 60) # MQTT server address
|
||||||
|
|
||||||
|
house_battery_soc = client.subscribe(topic_house_battery_soc)
|
||||||
|
house_battery_power = client.subscribe(topic_house_battery_power)
|
||||||
|
power_import_export = client.subscribe(topic_power_import_export)
|
||||||
|
pv_power = client.subscribe(topic_pv_power)
|
||||||
|
house_power = client.subscribe(topic_house_power)
|
||||||
|
car_soc = client.subscribe(topic_car_soc)
|
||||||
|
charge_point_power = client.subscribe(topic_charge_point_power)
|
||||||
|
|
||||||
|
|
||||||
logging.info("epd2in13b_V3 Demo")
|
logging.info("epd2in13b_V3 Demo")
|
||||||
|
|
||||||
epd = epd2in13b_V3.EPD()
|
epd = epd2in13b_V3.EPD()
|
||||||
@ -78,12 +80,9 @@ try:
|
|||||||
drawblack.text((2, 64), 'Batterie Entladen', font = font16, fill = 0)
|
drawblack.text((2, 64), 'Batterie Entladen', font = font16, fill = 0)
|
||||||
drawblack.text((2, 80), 'Auto Laden', font = font16, fill = 0)
|
drawblack.text((2, 80), 'Auto Laden', font = font16, fill = 0)
|
||||||
|
|
||||||
#drawblack.text((100, 80), str(charge_point_power), font = font16, fill = 0)
|
drawblack.text((100, 80), str(charge_point_power), font = font16, fill = 0)
|
||||||
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))
|
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#logging.info("Clear...")
|
#logging.info("Clear...")
|
||||||
#epd.init()
|
#epd.init()
|
||||||
#epd.Clear()
|
#epd.Clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user