Control Pages: basic questions

Posted on
Fri Mar 30, 2018 4:36 pm
dduff617 offline
Posts: 659
Joined: Jul 05, 2006
Location: Massachusetts, USA

Control Pages: basic questions

I find myself sometimes at a loss trying to do control pages that feel very basic - like there's probably some easy way to do it, but I can't seem to figure it out...

Here are a few examples, I feel sure others must have encountered at some point:

How do I represent the state of Z-wave door lock (locked vs. unlocked) on a control page? I can't seem to find any built-in images for lock state (e.g. a padlock icon or whatever) to use for control pages for locks, however I know Indigo client has built-in support for these in the Item Detail window.

How do I represent a device's battery level on a control page? I can't seem to find any built-in images to use for control pages for this. Indigo client has some custom support for displaying battery level for certain device types in the Item Detail window - would be nice if I could re-use or replicate something like that in a control page.

Is sharing of control page "fragments" or building blocks like images/icons supported? I know how to access the plugin library and there used to be a "File Library" that has a few sets of buttons and icons, but it appears the stuff supporting control pages there is a bit sparse... So is everyone just "rolling their own" in terms of images/icons to represent device states in control pages?

Posted on
Mon Apr 02, 2018 8:57 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Control Pages: basic questions

Is sharing of control page "fragments" or building blocks like images/icons supported? I know how to access the plugin library and there used to be a "File Library" that has a few sets of buttons and icons, but it appears the stuff supporting control pages there is a bit sparse... So is everyone just "rolling their own" in terms of images/icons to represent device states in control pages?

I believe for the most part people are either using the built-in images and doing a pretty basic page (which is fine) or else going all out and doing fully custom pages with nice background, custom images (either created themselves or "borrowed" on the internet).

However, you will find some image sets were shared when users created good icon sets -- you might get some ideas and links to download in this thread. It is long, might want to start at the back.

It would be nice if we had a way to post "profiles" - our control pages and resources associated with them - in an easy to view manner. However, being a forum that is a tall task to make.

Adam

Posted on
Mon Apr 02, 2018 9:15 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: Control Pages: basic questions

How do I represent a device's battery level on a control page? I can't seem to find any built-in images to use for control pages for this. Indigo client has some custom support for displaying battery level for certain device types in the Item Detail window - would be nice if I could re-use or replicate something like that in a control page.


I use a forum script someone else came up with to automatically generate a graph of this. Bonus, when I add a new device that is battery powered, the script automatically adds it to the graph.
No credit to me, and sorry I forget who came up with it. One of the usual suspects, I'm sure.

Code: Select all
#! /usr/bin/env python2.6
# -*- coding: utf-8 -*-

try:
    import sys
    import matplotlib.pyplot as plt
    import numpy as np
except ImportError, e:
    sys.exit(u"The matplotlib and numpy modules are required to use this script.")

# =================== User Settings ===================
output_file = '/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/images/controls/static/battery_test.png'

chart_title = 'Battery Levels'
x_axis_title = ''
y_axis_title = ''

background_color = '#000000'
chart_height = 4.5
chart_width = 6.15
font_color = '#000000'
font_name = 'Verdana'
font_size = 9
grid_color = '#888888'
grid_style = 'dotted'
show_data_labels = True
title_font_size = 9

battery_full_color = '#0000CC'
battery_caution_color = '#FFFF00'
battery_caution_level = 10
battery_low_color = '#FF0000'
battery_low_level = 5

# =================== kwarg Settings ===================
k_bar_fig = {'align': 'center',
             'alpha': 1.0,
             'height': 0.5,
             'zorder': 3
             }

k_grid_fig = {'which': 'major',
              'color': grid_color,
              'linestyle': grid_style,
              'zorder': 0
              }

k_plot_fig = {'bbox_extra_artists': None,
    'bbox_inches': 'tight',
        'dpi': 100,
            'format': None,
                'frameon': None,
                    'orientation': None,
                        'pad_inches': 0.1,
                            'papertype': None,
                                'transparent': True,
                                }

k_title_fig = {'fontname': font_name,
               'fontsize': title_font_size,
               'color': font_color,
               'position': (0.35, 1.0)
               }
# =====================================================

bar_colors = []
device_dict = {}
x_values = []
y_values = []

# Create a dict of battery powered devices and their battery levels
try:
    for dev in indigo.devices.itervalues():
        if dev.batteryLevel is not None:
            device_dict[dev.name] = dev.states['batteryLevel']

    if device_dict == {}:
        device_dict['No Battery Devices'] = '0'

except Exception, e:
    indigo.server.log(u"Error reading battery devices: %s" % e)

# Parse the battery device dict into X and Y values
try:
    for key, value in sorted(device_dict.iteritems(), reverse=True):
        x_values.append(float(value))
        y_values.append(key.replace(' - ', '\n'))  # This line is specific to my install, as I name devices "Room - Device Name"

        # Create a list of colors for the bars based on battery health 
        battery_level = float(value)
        if battery_level <= battery_low_level:
            bar_colors.append(battery_low_color)
        elif battery_low_level < battery_level <= battery_caution_level:
            bar_colors.append(battery_caution_color)
        else:
            bar_colors.append(battery_full_color)
except Exception, e:
    indigo.server.log(u"Error parsing chart data: %s" % e)

# Create a list of values to plot on the Y axis, since we can't plot on device names.
y_axis = np.arange(len(y_values))

# Plot the figure
plt.figure(figsize=(chart_width, chart_height))
# Adding 1 to the y_axis pushes the bar to spot 1 instead of spot 0 -- getting it off the axis.
plt.barh((y_axis + 1), x_values, color=bar_colors, **k_bar_fig)

if show_data_labels:
    for ii in range(len(y_axis)):
        plt.annotate("%3d" % x_values[ii], xy=((x_values[ii] - 5), (y_axis[ii]) + 0.88), xycoords='data', textcoords='data', fontsize=font_size, color=font_color)

# Chart
plt.title(chart_title, **k_title_fig)
plt.grid(**k_grid_fig)

# X Axis
plt.xticks(fontsize=font_size, color=font_color)
plt.xlabel(x_axis_title, fontsize=font_size, color=font_color)
plt.gca().xaxis.grid(True)
plt.xlim(xmin=0, xmax=100)

# Y Axis
# The addition of 0.05 to the y_axis better centers the labels on the bars
# (for 2-line labels.) For 1 line labels, change 1.07 to 1.0.
plt.yticks((y_axis + 1.05), y_values, fontsize=font_size, color=font_color)
plt.ylabel(y_axis_title, fontsize=font_size, color=font_color)
plt.gca().yaxis.grid(False)
plt.ylim(ymin=0)


# Output the file
plt.tight_layout()
plt.gca().spines['top'].set_visible((False))
plt.gca().spines['bottom'].set_visible((False))
plt.gca().spines['left'].set_visible((False))
plt.gca().spines['right'].set_visible((False))
plt.savefig(output_file, **k_plot_fig)
plt.close()

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Apr 02, 2018 9:50 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Control Pages: basic questions

dduff617 wrote:
Is sharing of control page "fragments" or building blocks like images/icons supported?


You can drag control pages from the list to the Finder and vice versa - the file created in the Finder is a clipping file that could be shared with others. Note however that images aren't shared - you need to package up those images separately. When you drag a clipping back in it will create the control page and you'll need to edit all the elements to point to your own devices.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 02, 2018 9:51 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Control Pages: basic questions

Different Computers wrote:
I use a forum script someone else came up with to automatically generate a graph of this. Bonus, when I add a new device that is battery powered, the script automatically adds it to the graph.
No credit to me, and sorry I forget who came up with it. One of the usual suspects, I'm sure.


That'd be me. I haven't made any changes to the script in a while, but here's a link to the relevant forum and you can find the download link for the most current version in post #1 there.

http://forums.indigodomo.com/viewtopic.php?f=202&t=15904

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

[My Plugins] - [My Forums]

Posted on
Mon Apr 02, 2018 10:03 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: Control Pages: basic questions

DaveL17 wrote:
That'd be me. I haven't made any changes to the script in a while, but here's a link to the relevant forum and you can find the download link for the most current version in post #1 there.

http://forums.indigodomo.com/viewtopic.php?f=202&t=15904


That script remains awesome! And bullet proof too. Never had one problem with it.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Apr 02, 2018 10:10 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Control Pages: basic questions

Glad to hear that it’s working well for you.


Sent from my iPhone using Tapatalk

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

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests