|
|
|
|
@@ -22,6 +22,7 @@ import json
|
|
|
|
|
import bottle as B
|
|
|
|
|
import tHome as T
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
def meter(client, data, cfg):
|
|
|
|
|
msg = {
|
|
|
|
|
@@ -30,7 +31,8 @@ def meter( client, data, cfg ):
|
|
|
|
|
"produced": data.Produced, # kWh
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ( cfg.mqttEnergy, msg )
|
|
|
|
|
return cfg.mqttEnergy, msg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
def instant(client, data, cfg):
|
|
|
|
|
@@ -39,7 +41,8 @@ def instant( client, data, cfg ):
|
|
|
|
|
"power": data.Power * 1000, # W
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ( cfg.mqttPower, msg )
|
|
|
|
|
return cfg.mqttPower, msg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
def price(client, data, cfg):
|
|
|
|
|
@@ -48,7 +51,18 @@ def price( client, data, cfg ):
|
|
|
|
|
"price": data.Price,
|
|
|
|
|
"tier": data.Tier,
|
|
|
|
|
}
|
|
|
|
|
return ( cfg.mqttPrice, msg )
|
|
|
|
|
return cfg.mqttPrice, msg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
def network(client, data, cfg):
|
|
|
|
|
msg = {
|
|
|
|
|
"status": data.Status,
|
|
|
|
|
"description": data.Description,
|
|
|
|
|
"linkstrength": data.LinkStrength
|
|
|
|
|
}
|
|
|
|
|
return cfg.mqttNetwork, msg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
handlers = {
|
|
|
|
|
@@ -59,13 +73,14 @@ handlers = {
|
|
|
|
|
"InstantaneousDemand": instant,
|
|
|
|
|
# "MessageCluster" :
|
|
|
|
|
# "MeterInfo" :
|
|
|
|
|
#"NetworkInfo" :
|
|
|
|
|
"NetworkInfo": network,
|
|
|
|
|
"PriceCluster": price,
|
|
|
|
|
# "Reading" :
|
|
|
|
|
# "ScheduleInfo" :
|
|
|
|
|
# "TimeCluster" :
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
|
|
|
|
|
@B.post('/')
|
|
|
|
|
@@ -90,6 +105,7 @@ def root_post():
|
|
|
|
|
|
|
|
|
|
return "ok"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
#
|
|
|
|
|
# Main applications script
|
|
|
|
|
|