CurrentCost Envi CC128 script

HouseBot Plugin Development Discussions.
Post Reply
edgar
Member
Posts: 95
Joined: Tue Mar 24, 2009 11:14 pm
Location: Springfield, VA

CurrentCost Envi CC128 script

Post by edgar »

Hi All,

I thought I would share a new script I just got working. I have a CurrentCost Envi PowerMeter device that measures power for your house. It has clamps that hook to your house wiring and measures your current electricity usage.

I am not a huge programmer but have managed to implement a very simple and crude vbs script that seems to be working. The CC128 can be added as a generic serial device to HB. When connected you see the continuous xml stream that comes in every 6 seconds. Below is a small script that can be used to parse the xml code based on Tag. Hope this can help someone else who has one of these devices. I am not an experienced coder so if there is anything I could tweak...let me know!
v/r

Kevin

' Dim your variables
Dim EnviXML
Dim NodeList
Dim NodeList2
Dim NodeList3
Dim NodeList4
Dim objXMLDOC
Dim Root

EnviXML = GetPropertyvalue("Envi PowerMeter.Received Data")

Set objXMLDOC = CreateObject("Microsoft.XMLDOM")

' do not forget to use loadXML vice just load. Load is for a file...not the raw XML!

objXMLDOC.async = False
objXMLDOC.loadXML(EnviXML)

Set Root = objXMLDOC.documentElement
Set NodeList = Root.getElementsByTagName("ch2/watts")
Set NodeList2= Root.getElementsByTagName("ch1/watts")
Set NodeList3= Root.getElementsByTagname("tmprF")
Set NodeList4= Root.getElementsByTagname("time")

For each Elem in NodeList
SetPropertyValue "Envi: Data.CH 1 watts", Elem.firstchild.nodeValue & vbLF
Next

For each Elem in NodeList2
SetPropertyValue "Envi: Data.CH 2 watts", Elem.firstchild.nodeValue & vbLF
Next

For each Elem in NodeList3
SetPropertyValue "Envi: Data.Temp in F", Elem.firstchild.nodeValue & vbLF
Next

For each Elem in NodeList4
SetPropertyValue "Envi: Data.Time", Elem.firstchild.nodeValue & vbLF
Next

Set objXMLDOC = Nothing
Post Reply