New to HASS/appdaemon so I’m having a bit of a struggle with some basic stuff. For instance I have an input_select that I want to use as a scene selection for my lights. Works fine with HASS. But now I want to create a dashboard and I want every value of the input select to be its own button. How to I do that?
you can create an automation to set each value from input_select and then use a button for every automation.
you can create an app and use input_booleans to set each value and then use a button for every input_boolean.
you could also use my custom input_select widget to create 1 button where you chose the setting.
but you have it to select scenes, so you could also use the scene widget to activate each scene directly, without using the input_select at all.
Thank you for the tips, will look into what you say! The reason I don’t use the builtin scene functionality is that I found it very limited. I actually don’t want to use any logic in HASS, only python code with dashboards.
FYI, this is what I’ve tested so far:
scene_widget:
widget_type: sensor
title: Scene
entity: input_select.scene_living
scene_normal:
widget_type: switch
entity: input_select.scene_living
state_active: Normal
scene_music:
widget_type: switch
entity: input_select.scene_living
state_active: Music
layout:
- scene_widget(2x1), scene_normal(2x1), scene_music(2x1)
It seems to work in that it will show the state of the input select (both the value in the first widget and enabling the corresponding switch accordingly). But if I click one of the switches, the value is not set to the input select. If I can only solve that, I’m good to go. Can it be done?
you cant use switch widget with input_select.
you need or scenes in HA with scene widget, or
an input boolean that triggers an app
or an automation in HA and a button for that.
you cant go around HA.
if you want to keep input_select you could try my custom input_select
Ok, good to know! I played a bit with scenes now, but as they require the entity states in yaml, it’s not really any good for me. I want to do everything programatically. But it sounds on you like input booleans could be a a workaround for me. I don’t really want a slider or a dropdown as I personally think it is not good for touch screens. If I use input booleans, I guess I would need one for each scene I have and a corresponding widget for that. Then there are two parts to solve that maybe you could help me with:
- When I click these widgets, how do I send an event to an app? Do the widget already send events by default?
- When the app changes the scene (input_select), how to I enable the corresponding input boolean widget in the dashboard? I guess I just set the state?
with an app you can go this way:
listen_state(callback, input_boolean.scene1)
listen_state(callback, input_boolean.scene2)
listen_state(callback, input_boolean.scene3)
def callback(self,entity,new,old,attributes,kwargs):
if new == "on":
device,entity = self.splitt_entity(entity)
self.call_sevice("input_select/set_value",value=entity)
self.turn_off(entity)
this is just pseudo code but it gives you an idea where to go
then you create an input_boolean for every part from your input_select and your good to go.
Perfect, thank you so much for your help!
Almost got it working, but I have one annoying problem left. As I both listen to changes on the input_select (and change the input_booleans accordingly) and the input_booleans (and change the input_select if needed), this will generate a loop. If I set the input_booleans programatically I would generate new events that would set it again and so on… Is there a way to change the input_boolean state without triggering an event? In openhab they solved this by having send_command and send_update…
Starting to think this might be too much work for the gain, thinking if it might be less work to try to write my own multi-button input_select widget. Not so good with js/css though, but…
nope there is no such way.
i would solve it by keeping them all to on. but then you cant see which one is active.
Ah, sucks… Oh well, I will experiment a bit more, but otherwise I guess I will look at your widgets instead for now
or just dont listen to the input select!!
and dont use it in ha, just hide it.
Mmm, but I don’t think that was the only problem. If I click one of the input_booleans, I will have to turn off all of the other ones programatically and that generates state changes as well, not sure how I can distinguish them from user input…
you only take action on the “state set to on”
so you can without problem set them all to off
init:
for inputboolean in self.args["booleans_list"]:
listen_state(callback, inputboolean)
#listen_state(callback2,"input_select.scenes")
def callback(self,entity,new,old,attributes,kwargs):
if new == "on":
device,entity = self.splitt_entity(entity)
#self.call_sevice("input_select/set_value",value=entity)
for inputboolean in self.args["booleans_list"]:
if entity != inputboolean:
self.turn_off(input_boolean)
#def callback(self,entity,new,old,attributes,kwargs):
#self.turn_on("input_boolean." + new)
in apps.yaml:
booleans_list:
- input_boolean.scene1
- input_boolean.scene2
- input_boolean.scene3
this cant create a loop
you only get into trouble if you also try to set an action for off.
why use the input_select at all in this case?
you got inputbooleans to select your choice.
init:
self.select_used = False
for inputboolean in self.args["booleans_list"]:
listen_state(callback, inputboolean)
listen_state(callback2,"input_select.scenes")
def callback(self,entity,new,old,attributes,kwargs):
if new == "on":
device,entity = self.splitt_entity(entity)
for inputboolean in self.args["booleans_list"]:
if entity != inputboolean:
self.turn_off(input_boolean)
if not self.select_used:
# an input_boolean is triggered so set the input_select. and that will trigger the input_boolean again
self.turn_off(entity)
self.call_sevice("input_select/set_value",value=entity)
else:
# the input_select has changed, so now we can do our action
self.select_used = False
*** do your scene action
def callback(self,entity,new,old,attributes,kwargs):
self.select_used = True
self.turn_on("input_boolean." + new)
so you could use the select also
You’re right, I guess I don’t really need the input_select any more, it just seemed convenient when I started as it is kinda like an enum. But I guess I could just as well hold that value internally in my app. I will try out your suggestion, thank again!
the forum is bugging, but i gave another option where you could use the select.
Yeah I’ve noticed. It works pretty good, only case left is that it is possible to turn off the current input_boolean by pressing it again, not 100% sure how prevent that without the risk of creating a loop again. Any ideas?
I guess I have to add a check on off to see if all of them are off and in that case turn on the last one again. It should not create a new loop as the next callbacks would see that one of them is now selected.