How do I set an led to a specific color?

Hello! I just recently bought a 7" fire tablet so I’m just beginning with AppDaemon & HADashboard. So far I have a basic dashboard set-up with a few widgets to control a Flux rgb led. For a lamp in my bedroom I have multiple widgets controlling the same led bulb as shown below


flux_01:
  widget_type: light
  entity: light.flux_01
  title: My Lamp
  
flux_01red:
  widget_type: light
  entity: light.flux_01
  title: My Lamp
  title2: Red
  icon_style_active: "color:red"
  on_attributes:
    brightness: 40
    rgb_color: 87, 0, 0

flux_01org:
  widget_type: light
  entity: light.flux_01
  title: My Lamp
  title2: Orange
  icon_style_active: "color:orange"
  on_attributes:
    brightness: 40
    rgb_color: 128, 46, 0

Screenshot_2018-05-18-00-35-49
The second two widgets are just using the on_attributes to set the rgb_color. Both widgets work as expected IF the light is off when I press each it will turn on with the correct color set. Also as expected, pressing any of the three widgets while the lamp is on will turn it off.
Instead of having this, I would like to keep the first widget as the the lamp on/off and brightness control but have the 2nd two widgets just be a plain colored squares that I could press would change the color of the lamp.
I’m not really sure where to start.

Do I need a scene or an automation to trigger? I understand some basic concepts of programing but nothing specific to python. Is this something I would do directly with an AppDaemon app. I’ve also been looking at node-red. I’m starting with two colors but hope to add more once I understand how to get started. I hoping this would be relatively simple to get started with. I have no idea how to write the code but I think the logic would be like this

press red square
  if lamp is off then turn turn on
  set lamp to red (rgb_color: 87, 0, 0)
# But never turn the lamp off
set the lamp color in the first icon to red

press orange widget
 if lamp is off then turn it on
set lamp to orange
# But never turn the lamp off
set the lamp color in the first icon to orange
#

Also what kind of widget do I use to trigger this

Thanks

you got a working widget, but you just want to change the look, right?
so you can chance the widgets appearence by the widget styles.

flux_01org:
  widget_type: light
  entity: light.flux_01
  icon_style_inactive: "color:orange"
  icon_style_active: "color:orange"
  widget_style: "background-color: orange"
  level_style: "color:orange"
  level_up_style: "color:orange"
  level_down_style: "color:orange"
  on_attributes:
    brightness: 40
    rgb_color: 128, 46, 0

now you got the same widget but all elements and the background are orange.
so it works the same, but it appears as an orange box

do the same with any other color you like.

i hope this is what you were looking for.

@ReneTode Thank you! This does show me how change the widget look but I think I need to have a different widget_type to reach my end goal.
Screenshot_20180518_123059

I didn’t mean to add a # in front of But never turn the lamp off in my OP. Maybe I made it confusing to understand my desired result. I don’t think I want the color widget (flux_01org) to be a default light widget. I think it needs to trigger an AppDaemon app or yaml automation or a scene or something. Please let me try explain again:

  • I do not want the color widget to turn the lamp OFF or control the brightness.

I would like for example to press the orange widget and the following things happen:

  • check if the lamp if the lamp is already on

  • if the lamp is ON then ONLY change the color to orange

    • Do Not turn the lamp off
    • Do Not change the brightness
  • if the lamp is OFF then

    • turn the lamp ON
    • change the color to orange
    • Do Not turn the lamp off
    • Do Not change the brightness

Can I do this by simply learning to create an AppDaemon app?
Do I need to first create something in Home Assistant that I call or trigger with HADashboard?


This is where I’m stuck. It seem like are multiple ways to achieve this but Im not sure what I all need to do.

oke, in that case you still needed to learn how to create a widget with 1 color, so no harm done.

what you want can be done with an app, but also with an automation.

  1. create an input_boolean for every color
  2. create an automation or an app that
    a) turns the lamp on
    b) changes the color
    c) set the input_boolean back to off.

when the boolean is turned off, nothing happens. (and it is normally always on)

it can be a simple app like

initialise():
  listen_state(callback,self.args["boolean"])
callback():
  call_sevice("light.turn_on", color=self.args["color"]

that app can be repeated in the yaml for every color

but if you are more familiar with automations, thats also possible with a simple automation.

1 Like

Thank you! I think that’s what I needed to know. I’m gonna give it try using an app. If I understand what the apps can do correctly it seems like it will be time better spent learning that approach over automations because understanding how to build an app will allow for more complicated tasks down the raod

in that case i advise you to start with the basics.

if you read that and understand it, you will for sure be able to create the app that you want to create your dashboard.

Good Morning!
Would you mind guiding me in the following? I am using a Widget “Alarm”. I would like to have the following: Widget background Green when alarm is disarmed, Red when Armed Away and Amber when Armed Home. I do not have strong experience at developing Apps as you show in your My-Appdaemon documentation. An example should certainly help me moving forward.
Best regards

thats by default not possible.
you would need to create a custom_widget and change things in the javascript.
it will be possible in a future version from appdaemon, but i cant give a timeframe for that now.