Trying to use sensor.phone_state as trigger, but can't set idle and ringing in the automation GUI

Hi all!

This is my first question posted, so please be gentle. Up until now (six months) I’ve managed just fine with searching and trying and failing, but this simple automation have me really baffled.

I’m trying to use sensor.phone_state as trigger, but I can’t set idle and ringing in the automation GUI. It’s predefined with unavailable and unknown and typing in idle and ringing doesn’t work/isn’t the way to do it, it seems.

I can see the state changes in the developer tools when the phone rings, so I know that’s working.

Am I using this sensor (sensor.phone_state) wrong? I’m using state as trigger, in the first step in the automation GUI. Should I’ve used something else?

I was hoping to do an automation myself, because I tried this blueprint, but it switched on all the lights and smart plugs, when it should’ve restored (switched on) only the ones that were flashing.

Is there anything I should add, to make it easier to understand what I’m trying to achieve and what it is I’m struggling with? I would think how HA is installed, versions and the yaml code for the automation, is irrelevant in this case, since it’s a very basic configuration and automation. Anything else I can add to this thread?

I have an automation that mutes my TV and Stereo when I’m on the phone. I’m not sure what you are asking for, but here’s what I’m using in yaml mode.

- alias: Phone Calls
  trigger:
#making a call:  idle to offhook
    - platform: state
      entity_id: sensor.phone_phone_state
      from: idle
      to: offhook

#answering a call: ringing to offhook
    - platform: state
      entity_id: sensor.phone_phone_state
      from: ringing
      to: offhook

#hanging up a call: offhook to idle
    - platform: state
      entity_id: sensor.phone_phone_state
      from: offhook
      to: idle

  condition:
    - condition: state
      entity_id: sensor.where_are_you
      state: 'Home'

  action:
    - service: script.media_source_amp_mute
    - service: script.media_source_tv_mute
1 Like

Thanks. Nice to see you can utilize that sensor and entity in yaml. I’m trying to use sensor.phone_state, but I can’t set idle and ringing in the automation GUI. It’s predefined with unavailable and unknown.

I’m not good at yaml, hence wanting to use the GUI. I tried to make it work with yaml, without the GUI. I copied you code (tried to), but it didn’t trigger the lamp.

alias: Test
trigger:
 - platform: state
   entity_id: sensor.sm_s908b_battery_state
   from: idle
   to: ringing
condition: []
action:
 - device_id: fc65bde7ed33d8d3d92391f4065c3ce8
   domain: light
   entity_id: light.skaplampe
   type: flash
mode: single

Here’s what I get from the GUI, when trying to override the predefined values.

alias: Test 2
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.sm_s908b_phone_state
    from: idle
    to: ringing
condition: []
action:
  - device_id: fc65bde7ed33d8d3d92391f4065c3ce8
    domain: light
    entity_id: light.skaplampe
    type: flash
mode: single

If I don’t specify what the state changes to, i triggers the lamp, but that’s not useful at all.

alias: Test 3
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.sm_s908b_phone_state
condition: []
action:
  - device_id: fc65bde7ed33d8d3d92391f4065c3ce8
    domain: light
    entity_id: light.skaplampe
    type: flash
mode: single

Your first example is using battery_state not phone_state.

I would suggest you go to developer tools and display the sensor.sm_s908b_phone_state then have someone call you and see what state the sensor changes to. Then use those 2 values in your automation.

I don’t use the gui, sorry

1 Like

Oh sh!te, didn’t catch the wrong sensor., there. Thanks. Will change that and report back.

I wrote in the first post that I can see the sensor working in developer tools.

Thinking a little more, I would probably only use to: ringing and ignore from state

When using the right sensor, and skipping the GUI, it works. Thank you for your example.