I would like to work with scenes, e.g. for my lights.
First I thought to use a string, which could have quite a lot of different values and it would be also readable for coding, e.g. “Cinema”, “Sleeping”, etc.
Unfortunately if I would like to have a selection within my sitemap, this becomes hard as it somehow need to have numbers and mapping seems not to work. Working with numbers would be technically possible but I had this for some similar approach for my Sonos grouping and I always need to double check the numbers, which is a drawback for coding.
Thank you a lot
Please show us what you are trying to do
Let’s say I want to select different grouping scenarios for my sonos sound system. We call them “tv”, “good morning” and “chilling”. Those 3 scenarios should be selected via either sitemap or a rule (e.g.for a more complex cinema rule that also controls light).
What do you recommend for this 3 different options? Potential solutions from my side:
- one switch item per scenario
- one number item for all scenarios
- one string item for all scenarios
As a lot of switch items seem to be overdone and numbers not intuitive for programming or debugging, string might be an alternative. But how to handle this within sitemap selection?
Maybe another solution works better anyhow.
Thanks and best
Selection item=MyStringItem mappings=["String1"="String1a", "String2"="String2a", "String2"="String2a"]
Generally in programming you would avoid booleans (Switch) whenever there might be more than just “true”/“false” - and favour some enumeration. Those enumerations can be numbers or strings, that’s mainly personal flavour. Depending on the programming language used, numbers or strings might be supported better than the other.
For your scenarios, add another scenario “OFF”. Think about them as “states” - you see that you can now model all as a “state machine”, which is a fundamental software developement pattern.
Thank you all for your replies. Actually you confirm most of my ideas. I just thought string mapping for selections do not work but it’s perfect!