Input_boolean toggle / turn_on_off in automation

Hi,

I have a weird problem trying to turn_on and turn_off input_boolean in an automation.
I tried service input_boolean.toggle, input_boolean.turn_off and input_boolean.turn_on with no success.

My automation are triggered but nothing change with my input_boolean.

First automation :

 - id: '1526351456212'
   alias: MQTT Sensor Pool Check OFF
   trigger:
   - entity_id: sensor.pooltemperaturestatus
     from: '1'
     platform: state
     to: '0'
   condition: []
   action:
   - data:
       entity_id: input_boolean.mqtt_sensorpooltemperature
     service: input_boolean.toggle 

second automation

- id: '1526351399623'
  alias: MQTT Sensor Pool Check ON
  trigger:
  - entity_id: sensor.pooltemperaturestatus
    from: '0'
    platform: state
    to: '1'
  condition: []
  action:
  - data:
      entity_id: input_boolean.mqtt_sensorpooltemperature
    service: input_boolean.toggle

any idea ?

thanks

Try using homeassistant.toggle in the service call rather than input_boolean.toggle.

Also, check the spacing to make sure it’s as required, some bits look a bit off.

I’d remove the condition line if you’re not using it, make the ordering tidier, put the service entry before the data entry - so something like this:

- id: '1526351399623'
  alias: MQTT Sensor Pool Check ON
  trigger:
    platform: state
    entity_id: sensor.pooltemperaturestatus
    from: '0'
    to: '1'
  action:
  - service: input_boolean.toggle
    data:
      entity_id: input_boolean.mqtt_sensorpooltemperature

Thanks for your comeback.

First, I realised that building automation with the GUI do not do “clean” config behind. I then rebuilt my automation like you wrote me.

Second, I realised too that by using the “toggle” service I just need one automaiton to do what I need.

So, i built this automation :

- id: '1526351399623'
  alias: MQTT Sensor Pool Check
  trigger:
    entity_id: sensor.pooltemperaturestatus
    platform: state
  action:
  - service: homeassistant.toggle
    data:
      entity_id: input_boolean.mqtt_sensorpooltemperature

But…i’m facing the same problem :frowning: Automation is triggered but my input_boolean do not change.

Any other idea guys ?

thanks,

homeassistant services (like toggle) just turn into another service call of the same type but to the domain of the entity. So, in this case, homeassistant.toggle just results in another service call to input_boolean.toggle anyway. I believe the idea behind having homeassistant services like these is to be able to apply a service to a collection of entities from different domains, e.g.:

action:
  service: homeassistant.turn_on
  entity_id:
    - switch.switch1
    - light.lightA

Have you tried changing input_boolean.mqtt_sensorpooltemperature directly, e.g., from the Services page (or even the States page) of the frontend?

Although the formatting of you last attempt is still a bit unusual, I think it is technically correct. That’s why I’m wondering about input_boolean.mqtt_sensorpooltemperature itself.

Having said that, you might try adjusting your automation a bit - something like this:

- id: '1526351399623'
  alias: MQTT Sensor Pool Check
  trigger:
    entity_id: sensor.pooltemperaturestatus
    platform: state
  action:
    service: input_boolean.toggle
    entity_id: input_boolean.mqtt_sensorpooltemperature

Yup, I tried changing the input_boolean by calling the service from the services page and it work.
That’s why i’m lost why it do not want to work from my automation.

Will try later today the adjustment you suggest.

Thanks for your time.

Hmm. Are you sure the automation is getting triggered? Can you open the automation in the frontend? If so you should be able to see when it was last triggered. You can also force a trigger to see if the actions run.

1 Like

Doesn’t look like its getting triggered. Especially if the services are working.

True, i didn’t think about the manual triger.
I just tried, I changed the automation like what you did and then fired manually the automation…nothing change on my input :frowning:

Will try later to remove everything’s in my automation.yaml, maybe I have something conflicting.

Well to continue my saga, I tried to clean-up my automation.yaml.

This is only what I have :

- id: '1526351399623'
  alias: MQTT Sensor Pool Check
  trigger:
    entity_id: sensor.pooltemperaturestatus
    platform: state
  action:
    service: input_boolean.toggle
    entity_id: input_boolean.mqtt_sensorpooltemperature

Still no luck.
I triggered manually my automation several times and nothing change on my input_booelan.
I begin to think that this type of sensor is not for me :expressionless:

can you share your input_boolean yaml?

yes

input_boolean:
  mqtt_pooltemperaturesensor:
    name: Sensor Pool Temperature
    initial: off
    icon: mdi:pool

Your problem is your name is wrong. You have:

  action:
    service: input_boolean.toggle
    entity_id: input_boolean.mqtt_sensorpooltemperature

you need to have:

  action:
    service: input_boolean.toggle
    entity_id: input_boolean.mqtt_pooltemperaturesensor

FYI you should always use _ between names so you can easily see typos

1 Like

Wow, seriously !!
I’m shy right now !!

Sorry guys, it works great now

1 Like

I may have a similar issue. trying to have a button within a card to toggle.

      - type: custom:mushroom-light-card
        layout: vertical
        icon: mdi:ceiling-fan
        name: Deck fan
        entity: input_boolean.deck_fan_new
        tap_action:
          - action: call-service
            service: input_boolean.toggle
            data:
              entity_id: input_boolean.deck_fan_new
          - action: call-service
            service: script.deck_fan_on_off

using the service from developer, it toggles the button, but tapping the button just run the script w/o changing the state.

Tap action doesn’t support a list