How to change input_boolean state from OFF/ON to Yes/No?

I have set up an input_boolean using the Helper, and have an Automation based on it & it works fine. But within the Lovelace Entity Card I want to change the state from showing Off / On to Yes / No - how might I acheive this?

Also, how would I get the mdi: icon to change colour (blue > yellow > blue) to reflect the change of state? Currently it is always blue.

Many thanks!

Could you just use a dropdown instead of a toggle as a helper?

for the color, use hass: instead of mdi: so it follow the state

Thanks @flyize ; I have created an input_state via Helper / Dropdown, but what Call Service Option would I use within Automations / Action section? None start with input_state :grimacing:

TIA

Did you mean to say input_select?

The service call to select an input_select’s option is input_select.select_option.

Input Select - Services

Sorry - I did mean input_select, yes. My bad.

The input_select.postbox_state_2 that I created (see below) doesn’t work within Lovelace, although my input_boolean.postbox_state does work, albeit with Off/On and not Yes/No, and no icon colour change despite using hass:mailbox instead of mdi:mailbox. Where might I have gone wrong here? Do I need to somehow associate Off with Yes and On with No? That would seem logical to me, but can’t see where I would do so.

TIA

Can you elaborate? Does it fail to be displayed? Does it fail to show its two options?

I created one and it appears like this in the Lovelace UI:

Screenshot_20210708-142359~2

I’ll try …

If I point a Lovelace Entity Card to binary_sensor.mailbox_pir_motion the colour of the icon changes from blue to yellow for ~10 seconds when I trigger the sensor, then goes back to blue. This is correct & what I would expect. The card is set up to be just a name & an icon, with no “state” showing. See below.

If I point another Lovelace Entity card to input_select.postbox_state_2, before I activate the Hue sensor it says No, with a blue icon. If I then activate the sensor (as confirmed by the first Entity card above), nothing happens with this input_select.postbox_state_2 Card. See below.

If I point a third Lovelace Entity card to input_boolean.postbox_state, it either correctly displays Off or On depending on the Automation, but the icon never changes colour.

All three cards now have hass:mailbox as an icon.

It does that because the binary sensor’s state is controlled by its integration.

You appear to have an automation that synchronizes the input_boolean’s state with the binary_sensor’s state. An entity’s icon color is fixed unless you enable the state_color option.

Do you have an automation to synchronize its state with the binary_sensor’s state? If you don’t then it explains why “nothing happens”.

Yes, happy with that.

I have added a state_color: true to the Entity Card, but it still doesn’t change colour.

- type: entity
  entity: input_boolean.postbox_state
  name: Mailbox 2
  icon: hass:mailbox
  state_color: true

Possibly not; these are the two Automations that I have, but I do not have a binary_state associated with postbox within Developer Tools; do I need to create one, and if so where?

- id: '1625664196226'
  alias: Postbox
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.mailbox_pir_motion
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: input_boolean.toggle
    target:
      entity_id: input_boolean.postbox_state
  - wait_template: ''
    timeout: 00:00:20
    continue_on_timeout: true
  mode: single
- id: '1625758938755'
  alias: Postbox (2)
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.mailbox_pir_motion
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: input_select.select_option
    target:
      entity_id: input_select.postbox_state_2
  - wait_template: ''
    timeout: 00:00:20
    continue_on_timeout: true
  mode: single

With apologies in advance if I am being a bit dim here, but I am still learning! :crazy_face:

I know the Entities Card supports it but I am not so sure about the Entity Card (it’s not mentioned in its documentation). Someone with more Lovelace experience will need to help you with that.

In the second automation you posted, it uses the input_select.select_option service call which specifies the correct target but overlooks to specify the desired state value (Yes or No). You need to add more information:

      - service: input_select.select_option
        target:
          entity_id: input_select.postbox_state_2
        data:
          option: 'Yes'

In addition, the automation should be designed to handle setting the input_select to Yes or No based on the binary_sensor’s state.


- alias: Postbox (2)
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.mailbox_pir_motion
  condition: []
  action:
  - service: input_select.select_option
    target:
      entity_id: input_select.postbox_state_2
    data:
      option: "{{ 'Yes' if trigger.to_state.state == 'on' else 'No' }}"
  - wait_template: ''
    timeout: 00:00:20
    continue_on_timeout: true
  mode: single

Not sure if this will help…
But I did something similar here

Many thanks again. I tried loads of combinations, and still couldn’t get it to quite work (but I did discover that an Entities Card does do state_color whereas an Entity Card doesn’t seem to). So I tried using a Condition Card instead, and that does do what I wanted (display when mailbox needs emptying) and it also gets around the problem of changing off/on to yes/no at the same time. :sunglasses:

I now have it so that

  • the top left “button” (see below) turns yellow every movement for ~10 seconds (driven by the Hue integration)
  • the middle Entities Card changes colour very time movement is detected and stays changed until the next event (but waits 20 seconds each time to prevent multiple actions).
  • the lower Condition Card only shows when the state is on. I will now change the text to be more useful :grinning:

I will move the Entities Card to an Admin tab, so that I can change the state manually if I ever need to.

So, via a slightly roundabout way I have got it to do what I wanted - but couldn’t have without the help from here. Thank You again!


Did the example I posted, showing how to set the input_select to either Yes or No, fail to work? This topic’s original question is how to change an input_boolean’s state to Yes/No but that’s not possible whereas it is for an input_select.