Page 6 of 8

Re: Battery Charting Script

PostPosted: Sun Jun 19, 2016 4:15 am
by DaveL17
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))

Re: Battery Charting Script

PostPosted: Sun Jun 19, 2016 5:41 am
by jalves
deleted. thought you asked for z-wave. Will be back with correct info shortly. ;)

Re: Battery Charting Script

PostPosted: Sun Jun 19, 2016 5:45 am
by jalves
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

Re: Battery Charting Script

PostPosted: Sun Jun 19, 2016 6:36 am
by DaveL17
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

Re: Battery Charting Script

PostPosted: Sun Jun 19, 2016 6:48 am
by DaveL17

Re: Battery Charting Script

PostPosted: Sun Jun 19, 2016 2:53 pm
by jay (support)
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.

Re: Battery Charting Script

PostPosted: Mon Jul 11, 2016 7:49 pm
by DaveL17
Moderator's Note: Moved to the Dave's Scripts forum.

Re: Battery Charting Script

PostPosted: Sun Nov 13, 2016 8:47 am
by Bollar
Don't forget to change that path to Indigo 7. :D

Re: Battery Charting Script

PostPosted: Sun Nov 13, 2016 9:35 am
by DaveL17
Bollar wrote:
Don't forget to change that path to Indigo 7. :D

Done!

Thanks for the reminder.

Re: Battery Charting Script

PostPosted: Mon Jan 13, 2020 9:45 am
by McJohn
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

Re: Battery Charting Script

PostPosted: Mon Jan 13, 2020 11:38 am
by DaveL17
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)

Re: Battery Charting Script

PostPosted: Mon Jan 13, 2020 12:17 pm
by McJohn
Thank you so much for the fast feedback!
We shall give it a try.

PS: works perfect! beautiful yellow circle! :D

Thumbs up!

Re: Battery Charting Script

PostPosted: Mon Jan 13, 2020 1:12 pm
by DaveL17
Glad to be of help.

Cheers!

Re: Battery Charting Script

PostPosted: Tue Jan 14, 2020 9:51 am
by McJohn

Re: Battery Charting Script

PostPosted: Tue Jan 14, 2020 10:31 am
by DaveL17
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 12592 times