Capturing real time data from Emporia Due

Posted on
Thu Dec 23, 2021 7:43 am
johnpolasek offline
Posts: 897
Joined: Aug 05, 2011
Location: Aggieland, Texas

Capturing real time data from Emporia Due

I don't have the skills to make this a plugin, but if called from a schedule this script can be used to pull real time data from the Emporia Cue 16 circuit mower monitor that I bought to replace a much more expensive sites age unit. It does use a free java implementation from a third party user on GitHub to download data from the Emporia cloud service because the company will not allow local access to the unit, but (at least for the moment) accessing the data is free. There is also a python library version of this downloader available, but I had already almost finished the java version before I found it. It will read the previous minute's data from all 16 channels and save it into Indigo variables that can be used to drive triggers, which I use primarily to know when the washer and dryer have finished... Sorry too add it in the body, but its short and for some reason it will not let me attach it.

Code: Select all
import os, shutil, datetime, time, subprocess
from time import strftime
from datetime import datetime, timedelta
import requests
from requests.auth import HTTPDigestAuth
from ast import literal_eval

#execute the data Downloader saving data to file rather than PIPE that might overflow buffer
p=subprocess.Popen('java -jar ~/documents/emporiadownloader/emporia-downloader.1.2.jar --username EMAIL --password PASSWORD --raw --scale m --disable-influx=true --history 1m --sleep 0 --quiet --logfile ~/documents/emporiadownloader/emporialog.txt >~/documents/emporiadownloader/emporiadata.json', shell=True)
# Read data from file
with open('~/documents/emporiadownloader/emporiadata.json', 'r') as infile:
   lines = infile.readlines()
# Convert the string representation of the data to individual dicts and get rid of any "null"s.
new_lines = [literal_eval(line.replace('null,null', '-1.0')) for line in lines]

# Combine into a single dict (optional)
line_dict = {}
x = 1
#Copy the data to the appropriate variables
for line in new_lines:
   line_dict[x] = line
   #if no data for channel keep prior value
   if line_dict[x]["usageList"][0] < 0 :
   #Convert total KWH for prior minute into average watts as a string
   Power = str(round(line_dict[x]["usageList"][0]*60000))
   #Load Power into the appropriate variable
   if line_dict[x]["channel"] == "1" :
      indigo.variable.updateValue(1205466672, value = Power)

   if line_dict[x]["channel"] == "2" :
      indigo.variable.updateValue(625300994, value = Power)

   if line_dict[x]["channel"] == "3" :
   #fan 2
      indigo.variable.updateValue(204858724, value = Power)

   if line_dict[x]["channel"] == "4" :
      indigo.variable.updateValue(366529428, value = Power)

   if line_dict[x]["channel"] == "5" :
      indigo.variable.updateValue(1510404434, value = Power)

   if line_dict[x]["channel"] == "6" :
   #Hot Water Heater
      indigo.variable.updateValue(1585403834, value = Power)

   if line_dict[x]["channel"] == "7" :
      indigo.variable.updateValue(1755332382, value = Power)

   if line_dict[x]["channel"] == "8" :
      indigo.variable.updateValue(1680593288, value = Power)

   if line_dict[x]["channel"] == "9" :
   #Living Room
      indigo.variable.updateValue(1097926420, value = Power)

   if line_dict[x]["channel"] == "10" :
   #Master 1
      indigo.variable.updateValue(1173427536, value = Power)

   if line_dict[x]["channel"] == "11" :
   #Master 2
      indigo.variable.updateValue(1811108695, value = Power)

   if line_dict[x]["channel"] == "12" :
      indigo.variable.updateValue(1176479276, value = Power)

   if line_dict[x]["channel"] == "13" :
      indigo.variable.updateValue(1096942489, value = Power)

   if line_dict[x]["channel"] == "14" :
      indigo.variable.updateValue(1911961433, value = Power)

   if line_dict[x]["channel"] == "15" :
      indigo.variable.updateValue(1670122551, value = Power)

   if line_dict[x]["channel"] == "16" :
      indigo.variable.updateValue(1252297191, value = Power)

   x += 1

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest