Pulling instantaneous demand using paho
this is a simple script to pull instantaneous demand using paho
import sys
import json
import paho.mqtt.subscribe as subscribe
def get():
d=''
try:
#r = requests.get(url = URL)
#d=r.text
msg = subscribe.simple("event/metering/instantaneous_demand", hostname="10.10.10.59", port=2883)
data = json.loads(msg.payload)
d=str(data['demand'])
except:
d= "0.000"
return d
subscription topics according to https://github.com/timothyf/dte-eb-connect/blob/master/src/config-topics.js
summation
remote/summation
event/metering/#
event/metering/summation/minute
remote/event/metering/summation/minute
event/metering/instantaneous_demand
remote/event/metering/instantaneous_demand
remote/request/metering/summation/minute
remote/response/metering/summation/minute/#
remote/request/announce
remote/response/announce/#
remote/request/metering/polling_mode/set
remote/request/metering/configure
remote/response/metering/configure
remote/response/metering/polling_mode/set
remote/request/wifi/current
remote/response/wifi/current/#
remote/request/timezone/set
remote/response/timezone/set
remote/request/ha_device/device_list
remote/response/ha_device/device_list/#
remote/request/demand_response/enlisted_devices
remote/response/demand_response/enlisted_devices
request/metering/polling_mode/get
response/metering/polling_mode/get/ble_data2
request/diagnostics/heartbeat_stats
response/diagnostics/heartbeat_stats/heartbeat273
event/diagnostics/zigbee
remote/event/diagnostics/zigbee
remote/request/is_app_open
remote/response/is_app_open/#
request/ebapi/post_minute_summations
request/ebapi/post_realtime
response/ebapi/post_minute_summations/minute_summations274
response/ebapi/post_realtime/realtime275