Need help with input_boolean in an automation

hi all,

firstly, i have no idea what I am doing, but i’m trying to understand…

here is what i have.

I have an Ikea light and an Ikea wireless dimmer both from the Tradfri range. i can turn the light on and change the brightness and colour temp via alexa. i can see both the light and the dimmer switch in my states page of home assistant. i dont have the ikea skill set on the alexa and I have unlinked the dimmer from the bulb.

What I want to happen.

if I turn the dimmer switch or use voice commands between sunrise and 10pm the light ill come on but the colour temp will be cool white, if i turn the switch at any other time the light will come on and be warm white. at 10pm the light will change to warm white if the light is already on even if i havent touched the dimmer switch.

i hope that makes sense.

i want to do the entire thing in HA as i want to add the the automation as i learn more and its going to be a learning exercise for me

ive been told that part of this is to link an input_boolean to alexa, i’ve tried to find how that works and what an input_boolean is but i’ve not found anything.

can anyone help me?

thank you in advance.

Really? What exactly did you try?

I just typed home assistant input_boolean in Google and it was literally the first thing in the list…

ex

Have you read the docs on Alexa via HA? Automations?

Have you tried writing any code yet?

Thanks for your response.

I tried searching on this forum and found lots of questions but nothing that explained to me what it is and how to use it, I also searched through the documentation that I could find though it only appeared to me to explain how to set up alexa to work with ha via skills settings (honestly on this it was way over my head and I got lost).

Never thought to try Google as I guessed this was the place to find the answers but thank you for pointing out my errors in searching.

No I haven’t tried to write any code as I didn’t know where to begin. I’ll go to Google, see if I can work some of it out and get back to you all…

Once again, thank you for your reply and for pointing me in this direction.

after reading the documentation found via google i have added the following to my configuration.yaml

input_boolean:
  alexa1:
    name: control dimmer switch
    initial: off

the “alexa1” i’ve taken from other automations that i’ve found while searching, i dont fully understand what i can put in here, if i can put anything as long as i use “_” instead of spaces or if there are a set list of values.

and tried the following in my automations

- id: '1543857081820'
  alias: bedside lamp
  trigger:
  - entity_id: sensor.tradfri_wireless_dimmer
    platform: state
    to: 'on'
  condition:
    condition: state
    entity_id: input_boolean.alexa1
    state: 'on'
  action:
  - service: light.turn_on
    entity_id: light.bedside1

though nothing is working, i tried removing the condition, thinking that the switch should at least turn on the lamp, but no, nothing happens… i checked the states page and turned the switch and nothing changes.

have i missed something in setting the switch? am i at least on the right track to getting this to work?

thank you for your help and time.

I’m not sure why you need to use an input boolean.

Have you set up some form of access from Alexa to your HA?

Are you sure that the dimmer switch actually has a state “on”?

just as a basic automation to get the light to turn on:

- id: '1543857081820'
  alias: bedside lamp
  trigger:
    - entity_id: sensor.tradfri_wireless_dimmer
      platform: state
      to: 'on'
  action:
    - service: light.turn_on
      entity_id: light.bedside1

try that first and we can go from there.

Make sure to set the initial_state variable to true to enable the automation all the time.

Not necessary. The default value is true if not specified.

No reason to confuse the issue more…

I’d personally try getting the automations working without Alexa first and then work out how to make Alexa call the automations afterwards. I don’t use Alexa personally, but use Google Home so I imagine it would similar…

As far as the automations go, I’ll take a stab and hopefully it gives you somewhere to start! I also don’t know what states your dimmer sensor uses so I am assuming it goes from 0 to some other value. Sensors usually don’t have an on or off state, they are an actual value. (I could be wrong)

You may have to fiddle around with some of these times and sun conditions, but start copying these one at a time in to your automations file and see which ones work and which don’t, and report back. The last two are the simplest ones so perhaps start with those… I haven’t coded in a while so this is going off memory and my own light automations :slight_smile:

# Automation between 10pm and sunrise using dimmer
- alias: Lamp 10pm to Sunrise
  trigger:
    platform: state
    entity_id: sensor.tradfri_wireless_dimmer
    from: 0
  condition:
    condition: or
    conditions:
    - condition: time
      after: '22:00:00'
    - condition: sun
      before: sunrise 
  action:
  - service: light.turn_on
    data:
     entity_id: light.bedside1
     color_temp: 333

# Automation between sunrise and 10pm using dimmer
- alias: Lamp sunrise to 10pm
  trigger:
    platform: state
    entity_id: sensor.tradfri_wireless_dimmer
    from: 0
  condition:
  - condition: sun
    entity_id: sun.sun
    after: sunrise
  - condition: time
    before: '22:00:00'
  action:
   - service: light.turn_on
     data:
      entity_id: light.bedside1
      color_temp: 175

# light change at 10pm
- alias: Light change at 10pm
  trigger:
  - platform: time
    at: '22:00:00'
  condition:
  - condition: state
    entity_id: light.bedside1
    state: 'on' 
  action:
  - service: light.turn_on
    data:
     entity_id: light.bedside1
     color_temp: 333

# light change at sunrise
- alias: Light change at sunrise
  trigger:
    platform: sun
    event: sunrise
  condition:
  - condition: state
    entity_id: light.bedside1
    state: 'on' 
  action:
  - service: light.turn_on
    data:
     entity_id: light.bedside1
     color_temp: 175

Also, the color temps are based on what my Xiaomi lights operate between, 175 being white and 333 being warm. You would need to check the states of you lights in the states section of Hassio to see what your colour temps are when you change them (it’ll show as an attribute under the entity), and you dimmer sensor values for that matter…

I honestly think that is WAY too much information for the OP right now.

They need to learn to crawl before learning to run.

That’s why I advised just getting the light to switch on first. Then after that we can build from there.

hi Finity,

i have no idea either, it was sugested to me in another post when a previous question of solved. I’ve tried asking there again with no reply.

i have the cloud set up for alexa (going into “Configuration” and setting up “home assistant cloud” ) which means I can control all my bulbs and switches by voice.

no i’m not sure of anything if Im honest, i tried looking at the states page in HA under the dimmer switch and all I see is this:

[sensor.tradfri_wireless_dimmer]
(http://hassio.local:8123/dev-state#) 74
manufacturer: IKEA of Sweden
model_number: TRADFRI wireless dimmer
serial:
firmware_version: 1.2.248
power_source: Battery
battery_level: 74
unit_of_measurement: %
friendly_name: TRADFRI wireless dimmer

if I turn the dimmer (even when it was paired with the bulb via the tradfri app) nothing on the states changed except the battery percentage, though the bulb would turn on and off and get brighter or dimmer. as it stands just now with the switch not paired, it does nothing at all.

i’ve tried the following code:

- id: '1543857081820'
  alias: bedside lamp
  trigger:
  - entity_id: sensor.tradfri_wireless_dimmer
    platform: state
    from: 0
#  condition:
#    condition: state
#    entity_id: input_boolean.alexa1
#    state: 'on'
  action:
  - service: light.turn_on
    entity_id: light.tradfri_bulb_e14_ws_opal_400lm

and the below :

- id: '1543857081820'
  alias: bedside lamp
  trigger:
  - entity_id: sensor.tradfri_wireless_dimmer
    platform: state
    to: 'on'
#  condition:
#    condition: state
#    entity_id: input_boolean.alexa1
#    state: 'on'
  action:
  - service: light.turn_on
    entity_id: light.tradfri_bulb_e14_ws_opal_400lm

both work if I click “trigger” in the automation on the front end screen but nothing happens is I turn the dimmer switch.

I did find that for some reason the automation does not work if I use the friendly name for the bulb so I changed that for the name listed in the states page.

for the bulb the attributes range is :

Brightness: 1 - 254

color_temp: 250 - 454

my states for the bulb at max :

[light.tradfri_bulb_e14_ws_opal_400lm]
(http://hassio.local:8123/dev-state#) on
min_mireds: 250
max_mireds: 454
brightness: 254
color_temp: 454
friendly_name: bedside1
supported_features: 35

i have other automatons based on time and sunrise and they all work fine, just getting this switch to work via HA if I could do that, i think i could get what I am after with conditions except maybe the bulb changing color_temp at a set time even if it is on but I haven’t tried that to know yet, so I’ll cross that bridge when I come to it :slight_smile:

thank you all for your help and time

Those two things don’t seem to line up.

you are calling it a switch (which would also be my understanding of a device that controls the dimming) but you are showing a sensor (which is a device that detects some thing.

Can you take a screenshot of the dimmer and post it here?

What you are listing above looks like the attributes of the dimmer not the state.

Ahhh… never noticed that…

i’ll try and post details here…



the “sensor” i’m trying to use is this

https://www.ikea.com/gb/en/products/lighting/smart-lighting/trådfri-wireless-dimmer-white-art-00347831/

hope that helps

you cut off the top of the dimmer in your last pic. please try again showing the whole dimmer section.

I have an idea what you need to get started but I want to be sure.

sorry about that,

here you go

OK, from that screen shot you can see that the “state” (middle column) of the dimmer is “60”.

So, try this and see if the light turns on when you take the dimmer from all the way off (‘0’) to something higher (>‘0’):

- id: '1543857081820'
  alias: bedside lamp
  trigger:
    - entity_id: sensor.tradfri_wireless_dimmer
      platform: numeric_state
      above: 0
  action:
    - service: light.turn_on
      entity_id: light.tradfri_bulb_e14_ws_opal_400lm

nothing happend, that value ‘60’ appears to be the battery percentage as the two values are always the same

just to be sure though… here is what I typed in

- id: '1543857081820'
  alias: bedside lamp
  trigger:
  - entity_id: sensor.tradfri_wireless_dimmer
    platform: numeric_state
    above: 0
  action:
  - service: light.turn_on
    entity_id: light.tradfri_bulb_e14_ws_opal_400lm

If you operate the dimmer device the number in the “state” column doesn’t change?

thats correct

I’m not familiar with the dimmer.

How did you integrate it into HA?

Is that the only entity (the sensor) that got created in HA when you added it?