Advice on exposing week profile ids and names to the user in a binding

I am helping a friend creating a binding for controlling panel heaters from Glen Dimplex. The heart of the binding is the connection to a Hub device which acts as a a bridge, with one or more things that can either be a Zone or Component, where a Zone is one of more Components, which can be a panel heater or a wall switch. The focus here will be on controlling the Zones.

The Hub device has a concept of Week Profiles for setting when during hour/day you want a Zone set to a given mode, like On, Off, Eco or Away. The week profiles are configured globally, meaning they can be assigned to zero or more zones.

The issue I am having is how to expose the week profiles to the user of the binding. Each week profile has an assigned number in the Hub Device, meaning the if we want to change week profile for a zone, we can send a message to the device with the new number. For this I have created a channel called activeWeekProfile, which always shows the active profile as a number.

To control it I have created a selection in a sitemap like this

  Selection item=MainBedroom_Zone_WeekProfile  mappings=[0="Default", 4="OFF", 7="On", 9="Eco", "12"="My Custom week profile with long name"]

But to do this I needed to extract the correct Week Profile ids and names from the Hub Device as a string type channel on the bridge device. This is a channel that lists out all the profiles as a long string in the format “id1=name1,id2=name2,…”. If the user has 3 or 4 profiles with short names this should not be a problem, but it you have a lot of week profiles the string is quickly overflowed in the sitemap. As sitemaps does not seem to have a textarea type or viewmode this quickly gets problematic for the user to view when creating their own sitemaps.

Having a map/list item type would have been a good way to solve this, but reading up on the forum made me understand this does not exist.

Does anyone have a suggestion on how to create a channel or present a map/list of week profiles to the user?

Have you looked into using a DynamicStateDescriptionProvider to dynamically set the state options on the channel? When you use a Selection widget and an item linked to channel with dynamic state options, you can present the list of options to the user just like what you’re doing now (but without the need for the mapping parameter).

See here.

This looks very promising. Will have a go implementing the activeWeekProfile using DynamicStateDescriptionProvide.

Search through the addons repo. There are a number of bindings that use it that you can use as examples.

The wled binding uses that method and is a pretty basic binding that should be easy to follow if you need an example.

Thanks for the excellent feedback. The activeWeekProfile now works exactly as I wanted it to, by updating the options on the fly via DynamicStateDescriptionProvide.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.