Battery Charting Script

Posted on
Sun Jun 19, 2016 4:15 am
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script

Request:

Can someone with a battery-powered Insteon device please run the following script against one device and post (or PM) the result?

Thanks.
Dave

Code: Select all
dev = indigo.devices[DEVICE ID GOES HERE]
indigo.server.log(unicode(dev))

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Jun 19, 2016 5:41 am
jalves offline
Posts: 549
Joined: Jun 16, 2013

Re: Battery Charting Script

deleted. thought you asked for z-wave. Will be back with correct info shortly. ;)

Running Indigo 7.4 on a 27" iMac (mid-2017), 40G memory, 1T Fusion Drive, OS X 10.15.2
Jeff

Posted on
Sun Jun 19, 2016 5:45 am
jalves offline
Posts: 549
Joined: Jun 16, 2013

Re: Battery Charting Script

OK, here is the output from an Insteon motion sensor:

Code: Select all
  Script                          address : 23.24.0A
allowOnStateChange : True
allowSensorValueChange : False
batteryLevel : None
buttonGroupCount : 3
configured : True
description : Motion Sensor in Jeff's Closet

deviceTypeId :
displayStateId : onOffState
displayStateImageSel : MotionSensor
displayStateValRaw : False
displayStateValUi : off
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 1937631029
globalProps : MetaProps : (dict)
id : 73317655
lastChanged : 2016-06-19 06:23:07
model : Motion Sensor
name : Jeff Closet Motion Sensor
onState : False
ownerProps : emptyDict : (dict)
pluginId :
pluginProps : emptyDict : (dict)
protocol : Insteon
remoteDisplay : True
sensorValue : None
states : States : (dict)
     onOffState : off (on/off bool)
subModel :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : False
version : 65

Running Indigo 7.4 on a 27" iMac (mid-2017), 40G memory, 1T Fusion Drive, OS X 10.15.2
Jeff

Posted on
Sun Jun 19, 2016 6:36 am
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script

There's the trouble. The device is reporting a batteryLevel: None. I don't see anything in that dict that shows the status of the battery. I'll do a bit more digging to see if there's a way to check the battery level of Insteon devices in some universal way.

Thanks for the help.
Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Jun 19, 2016 6:48 am
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script


I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Jun 19, 2016 2:53 pm
jay (support) offline
Site Admin
User avatar
Posts: 15959
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Battery Charting Script

I don't believe there are any Insteon devices that actually report battery level. Mostly they have a special group that turns on when the battery gets low.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jul 11, 2016 7:49 pm
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script

Moderator's Note: Moved to the Dave's Scripts forum.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Nov 13, 2016 8:47 am
Bollar offline
Posts: 520
Joined: Aug 11, 2013

Re: Battery Charting Script

Don't forget to change that path to Indigo 7. :D

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Sun Nov 13, 2016 9:35 am
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script

Bollar wrote:
Don't forget to change that path to Indigo 7. :D

Done!

Thanks for the reminder.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jan 13, 2020 9:45 am
McJohn offline
User avatar
Posts: 435
Joined: Dec 18, 2012
Location: The Netherlands

Re: Battery Charting Script

Thanks for this nice script. Works perfect!

Is it possible to make a script per selected Indigo device?
For example only for the battery level of 1 motion sensor in the main control page?
(with nice green status leds :D ) , like the device details in the Indigo Device window)

Kind regards,
John

Posted on
Mon Jan 13, 2020 11:38 am
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script

Glad the script is working for you.

Unfortunately, there's no easy way to do what you want with the existing script. But I whipped together a silly script that should get pretty close to what you want. You'll need to customize it for each device (device ID, image file name, etc.). You can also customize the various cut-offs for the color of the image if you like. It places the resulting image file into the static images folder.

Code: Select all
import matplotlib.pyplot as plt

image_name = 'circle'
dev = indigo.devices[557779026]
battery_level = dev.states['batteryLevel']
path_name = indigo.server.getInstallFolderPath()

if battery_level <= 5:
   indicator = 'red'
elif battery_level <= 10:
   indicator = 'yellow'
else:
   indicator = 'green'

plt.figure(figsize=(0.5,0.5))
plt.scatter(3, 9, s=300, color=indicator)
plt.axis('off')

plt.savefig('{0}/IndigoWebServer/images/controls/static/{1}.png'.format(path_name, image_name), transparent=True)
Attachments
circle.png
circle.png (607 Bytes) Viewed 181 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jan 13, 2020 12:17 pm
McJohn offline
User avatar
Posts: 435
Joined: Dec 18, 2012
Location: The Netherlands

Re: Battery Charting Script

Thank you so much for the fast feedback!
We shall give it a try.

PS: works perfect! beautiful yellow circle! :D

Thumbs up!

Posted on
Mon Jan 13, 2020 1:12 pm
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script

Glad to be of help.

Cheers!

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jan 14, 2020 9:51 am
McJohn offline
User avatar
Posts: 435
Joined: Dec 18, 2012
Location: The Netherlands

Re: Battery Charting Script


Posted on
Tue Jan 14, 2020 10:31 am
DaveL17 offline
User avatar
Posts: 5194
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Battery Charting Script

McJohn wrote:

FYI, Matplotlib will also accept hex color codes as strings. For example,

Red = '#FF0000'
Green = '#00FF00'
Blue = '#0000FF'
White = '#FFFFFF'
Black = '#000000'
Greys = '#111111' - '#999999'

Using hex gives access to all 16.7 million colors. You can use the Mac Colors picker (for example through my Multitool plugin) which will show you the hex value of any color you choose. Using hex is my preference.

Screen Shot 2020-01-14 at 10.28.40 AM.png
Screen Shot 2020-01-14 at 10.28.40 AM.png (54.55 KiB) Viewed 112 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 1 guest