Hey Insteon users!

@kbrown01 hi from the reddit thread you linked to this!

i’m a little lost. would you be willing to set up a github repo that just shows your modified files. or consolidate your improvements here in a single how-to post? i realize it’s a lot to ask.

is this a template sensor?

as mentioned above – it would be great to just see some sample config files with this all together if you’re willing to share. configuration.yaml, sensor.yaml, the entire lovelace page, etc. – everything that one needs to construct the amazing @kbrown01 recipe. it’s clear this improves the experience drastically and should be considered building in to the official release.

I can pull it together possibly today

1 Like

Thanks. A lightbulb went off when I read your posts. I really gave up on group management when I switched from Indigo to HA 4 years ago.

It’s honestly a shame the indigo folks didn’t go all in on HA and just port the entire product over, coming up with some paid support model. All the design patterns are established and the software represents years of customer feedback. Unfortunately they will probably go out of business chasing a model that nobody wants anymore.

@jkmaxwell … best I could get to today. I extracted everything and uploaded to GITHUB.

If you find I missed something, let me know.

I, too, made local copies of the documentation for my Insteon devices. I would be glad to post them. Just let me know where and the incantation to put them there.

OSD

@kbrown01, I got most of your code working over the past few days. I actually just learned about the packages features that lets all of the config live together and I testing it for another component. The next time I get free time, I’ll try to create a package for the scene explorer because it REALLY simplifies adding this to your config.

1 Like

@kbrown01 thank you so much! i have some of it working – where do you put/how do you integrate input_select.yaml and template.yaml?

1 Like

I use configuration.yaml with includes … as in:

default_config:

zone: !include zones.yaml
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
rest: !include rest.yaml
rest_command: !include rest_command.yaml
sensor: !include sensor.yaml
binary_sensor: !include binary_sensor.yaml
template: !include template.yaml
light: !include light.yaml
input_boolean: !include input_boolean.yaml
input_number: !include input_number.yaml
input_select: !include input_select.yaml
media_player: !include media_player.yaml
timer: !include timers.yaml
var: !include vars.yaml
camera: !include cameras.yaml

So they are local YAML files in the same directory as configuration.yaml and the include the opening namespace (like input_select:) so you don’t repeat it.

1 Like

got it! moving that all to includes now.

1 Like

@kbrown01 thanks again, i’m so close! so i’m seeing 4 groups i have no idea about. do you recommend just nuking them and starting fresh? or can i learn more about how and what they are doing?

#1 … leave 254 alone! There was a setting in those files that had a max value. I set mine to 100 but I see you have a 105. You should change that to not include 254. I think at one time I hit 254 and it reset my Hub (not sure, may have been something else).

You are in a similar position as I was then. You can go to the Insteon Control Panel now. Select the Hub and at the top select the All-Link Database. Clicking the “Group” header you can sort by groups and see what is suppose to be in there. You will see many “0” and “1” and possible “2” to “8”. These are typically not “groups” but the buttons themselves.

Like for me, I have Group “49” and if I do what I said I see this:

And in looking at the devices try and figure out what they are. Like I have “4B.2B.87” which I can find in Select Device and gets it friendly name. This helped me to name all my groups.

Thanks. I’m still getting a bunch of errors.

2022-07-05 13:55:22 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'None' has no attribute 'attributes' when rendering '{% set scene_number = (state_attr('input_select.insteon_modem_groups','options')[repeat.index - 1]) %} {% set glist = states.sensor.insteon_group_names.attributes %} {% set gstring = namespace(grname=[]) %}  {% set gstring.grname = 'Insteon Group ' + scene_number %} {% for gname in glist %} {% if state_attr('sensor.insteon_group_names',gname) == scene_number %} {% set gstring.grname = gstring.grname + ' (' + (gname | replace('_',' ')) + ')' %} {% endif %} {% endfor %} {{ gstring.grname }}'
2022-07-05 14:32:11 WARNING (MainThread) [homeassistant.helpers.entity_component] Forced update failed. Entity sensor.insteon_group_names not found.
2022-07-05 14:32:14 ERROR (MainThread) [homeassistant.config] Invalid config for [template]: [name] is an invalid option for [template]. Check: template->name. (See /config/template.yaml, line 10). 
2022-07-05 14:32:14 ERROR (MainThread) [homeassistant.config] Invalid config for [template]: [name] is an invalid option for [template]. Check: template->name. (See /config/template.yaml, line 36). 

any ideas?

Might be timing issues. What do you see if you look at that entity in Developer Tools?

The image is mine with all the groups.

The new posting suggests you have an issue with what is inside template.yaml. Post that here.

and

##
## These are template sensors. 
##
## Given an insteon Scene Number, return a list of entities
## This requires two pieces of information, the target address as well as the group number for multi-button, multi-outlet devices.
## In the code for the sensor, first a list is created using the Insteon Address and the actual button (or outlet) number
## Then this list is parsed against the entities themsleves to get the entities in the given Insteon Scene
##
## sensor.insteon_scene_entities
##
  - name: insteon_scene_entities
    state: "{{ 'OK' }}"
    attributes:
        scene_entities: "
{% set glist = state_attr('sensor.insteon_groups','groups') %}
{% set devices = namespace(switch=[]) %}
{% for value in glist %}
{% if (value.group | int == states('input_select.insteon_modem_groups') | int)  %}
{% set devices.switch = devices.switch + [(value.device_address[0:2] + '.' + value.device_address[2:-2] + '.' + value.device_address[-2:] + '_' + value.button | string) | upper] %}
{% endif %}
{% endfor %}
{% set gp = namespace(groups=[]) %}
{% for ent in integration_entities('insteon') %} 
{% if state_attr(ent,'insteon_address') + '_' + state_attr(ent,'insteon_group') | string in devices.switch %} 
{% set gp.groups = gp.groups + [ent] %}
{% endif %} 
{% endfor %} 
{{ gp.groups | unique | sort }}"

##
## This sensor for scene names and numbers is created by hand based on my installation. There is no local storage in the ALDB or hub where the group names from the Insteon app are stored.
## Using the app or just based on experiements, you can create a map like below for scene names and scene number.
## This just helps you use some friendly names but can be used in automations/scripts for turning on an Insteon scene by using a friendly name.
##
## sensor.insteon_group_names
##
  - name: insteon_group_names
    state: "
    {% for gpname in states.sensor.insteon_group_names.attributes %}
    {% if state_attr('sensor.insteon_group_names',gpname) == states('input_select.insteon_modem_groups') %} 
    {{ gpname | replace('_', ' ') }}
    {% endif %}
    {% endfor %}"
    attributes:
        Dining_Room: 10
        Studio: 11

Is this because i’m trying to define groups my insteon doesn’t believe exist yet?

I never tried that, I only created the group names after I knew them all. I would at least put every known group into the list. Or if you do not know, just put in something like:

Unknown_Group_34: 34
Unknown_Group_36: 36

Until you figure out what you called it.

it definitely does not like my template file!

2022-07-05 20:30:12 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 1 when rendering '{{ states.input_select.insteon_devices.state.split('(')[1].split(')')[0] }}'
2022-07-05 20:30:12 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ states.input_select.insteon_devices.state.split('(')[1].split(')')[0] }}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 409, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1842, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "
  File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 326, in getattr
    value = getattr(obj, attribute)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1868, in _fail_with_undefined_error
    raise ex
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1859, in _fail_with_undefined_error
    return super()._fail_with_undefined_error(*args, **kwargs)
jinja2.exceptions.UndefinedError: list object has no element 1
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 525, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 411, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: list object has no element 1
2022-07-05 20:30:12 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: list object has no element 1') while processing template 'Template("{{ states.input_select.insteon_devices.state.split('(')[1].split(')')[0] }}")' for attribute '_attr_native_value' in entity 'sensor.selected_insteon_device'
2022-07-05 20:30:12 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ states('input_number.target_insteon_group')|int }}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 409, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1842, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1634, in forgiving_int_filter
    raise_no_default("int", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1331, in raise_no_default
    raise ValueError(
ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ states('input_number.target_insteon_group')|int }}' but no default was specified
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 525, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 411, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ states('input_number.target_insteon_group')|int }}' but no default was specified
2022-07-05 20:30:12 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ states('input_number.target_insteon_group')|int }}' but no default was specified') while processing template 'Template("{{ states('input_number.target_insteon_group')|int }}")' for attribute '_attr_native_value' in entity 'sensor.targeted_insteon_group'

this is my template file:

##
## These are template sensors. 
##
## Given an insteon Scene Number, return a list of entities
## This requires two pieces of information, the target address as well as the group number for multi-button, multi-outlet devices.
## In the code for the sensor, first a list is created using the Insteon Address and the actual button (or outlet) number
## Then this list is parsed against the entities themsleves to get the entities in the given Insteon Scene
##
## sensor.insteon_scene_entities
##
  - name: insteon_scene_entities
    state: "{{ 'OK' }}"
    attributes:
        scene_entities: "
{% set glist = state_attr('sensor.insteon_groups','groups') %}
{% set devices = namespace(switch=[]) %}
{% for value in glist %}
{% if (value.group | int == states('input_select.insteon_modem_groups') | int)  %}
{% set devices.switch = devices.switch + [(value.device_address[0:2] + '.' + value.device_address[2:-2] + '.' + value.device_address[-2:] + '_' + value.button | string) | upper] %}
{% endif %}
{% endfor %}
{% set gp = namespace(groups=[]) %}
{% for ent in integration_entities('insteon') %} 
{% if state_attr(ent,'insteon_address') + '_' + state_attr(ent,'insteon_group') | string in devices.switch %} 
{% set gp.groups = gp.groups + [ent] %}
{% endif %} 
{% endfor %} 
{{ gp.groups | unique | sort }}"

##
## This sensor for scene names and numbers is created by hand based on my installation. There is no local storage in the ALDB or hub where the group names from the Insteon app are stored.
## Using the app or just based on experiements, you can create a map like below for scene names and scene number.
## This just helps you use some friendly names but can be used in automations/scripts for turning on an Insteon scene by using a friendly name.
##
## sensor.insteon_group_names
##
  - name: insteon_group_names
    state: "
    {% for gpname in states.sensor.insteon_group_names.attributes %}
    {% if state_attr('sensor.insteon_group_names',gpname) == states('input_select.insteon_modem_groups') %} 
    {{ gpname | replace('_', ' ') }}
    {% endif %}
    {% endfor %}"
    attributes:
        Unknown_Group_34: 34
        Unknown_Group_36: 36
        Unknown_Group_105: 105
        Unknown_Group_254: 254

and when i try to change the select item i get this:

2022-07-05 20:39:30 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities input_number.target_insteon_group or it is/they are currently not available
2022-07-05 20:39:30 WARNING (MainThread) [homeassistant.helpers.entity_component] Forced update failed. Entity sensor.insteon_group_names not found.
2022-07-05 20:39:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'None' has no attribute 'attributes' when rendering '{% set scene_number = (state_attr('input_select.insteon_modem_groups','options')[repeat.index - 1]) %} {% set glist = states.sensor.insteon_group_names.attributes %} {% set gstring = namespace(grname=[]) %}  {% set gstring.grname = 'Insteon Group ' + scene_number %} {% for gname in glist %} {% if state_attr('sensor.insteon_group_names',gname) == scene_number %} {% set gstring.grname = gstring.grname + ' (' + (gname | replace('_',' ')) + ')' %} {% endif %} {% endfor %} {{ gstring.grname }}'

i’ll try to find out how to nuke these groups from any devices and then try this all again. In both Indigo & Insteon-MQTT we could remove links but it doesn’t appear we can from the native integration.

@kbrown01 Thanks for all the hard work on this dashboard. I’ve been following it for a few weeks, but only get a few hours here and there to work on it.

This is the first work I’ve done with Home Assistant, but your explorer was a great starting point!

I figured out a few new things including the use of “packages” in HA and have created a pull request against your repo @ https://github.com/kbrown01/insteon-scene-explorer/pull/3

@jkmaxwell - I saw that you created a pull request as well. Since you are using the code too, It’d be great if you could be a second set of eyes on the code or even try out the package version for some feedback.

1 Like

Thanks guys! Looks like some great changes here. I will go back and revisit them in a while. I am a little stuck right now not because of this … much of this exists for us to control things at our winery. And the most important thing is “da music”. The latest updates in HA broke the monoprice installation and I modified that for the Dayton Audio DAX88 … so I am caught without being able to change anything right now during high season for wine tasting.

When I get finished with that I will post to Github the update to support the audio.
Then I have a full Vizio Television and DirecTV remote system that kicks and have been working with folks on that one.
And then the iBBQ-4T meat thermometers.

Because as stated, once Insteon is up and running I am not adding many more devices (I do have maybe 10 more switches/dimmers/outlets to put in. At that time I will revisit this and get back to it.

All I can say is this is so fun, especially with help from folks like you.

1 Like

In the native integration you mark them as not in use. This is what is really happening in the other solutions as well in reality. I chose to have them still show up (but hidden by default) because I find that I sometimes want to activate and deactivate links on occasion. By making them available to view it makes it easier to reactivate an old link if you want to vs recreating the link from scratch.