Fritzbox call monitor/Squeezebox integration & automation: trying to restore state after call, help is very welcome

Tags: #<Tag:0x00007fc3fe128ff8> #<Tag:0x00007fc3fe128e90> #<Tag:0x00007fc3fe128d50>

Hi all

I have created an automation for when the (fixed, VoIP) phone is used; it’s triggered when dialing/calling or when the phone rings.
What happens next is with scene.create I track the state of 2 Logitech Squeezebox players and a light, the volume of those 2 players are changed and after ending the call that temporary scene is restored.
This has worked well for some time but it seems that in the process of upgrading, restoring that scene doesn’t go as expected: the playlist gets deleted except for the current playing song.

I have recreated the automation more then once to no avail…
Can anyone please have a look at this or tell me where to start on tackling this?

First automation to record the state:

- id: '1592951986553'
  alias: FB Rings -> squeezeplayer
  description: Incoming calls
  trigger:
  - entity_id: sensor.phone
    from: idle
    platform: state
    to: ringing
  - entity_id: sensor.phone
    from: idle
    platform: state
    to: talking
  - entity_id: sensor.phone
    from: idle
    platform: state
    to: dialing
  condition:
  - condition: state
    entity_id: media_player.living
    state: playing
  action:
  - data:
      scene_id: before
      snapshot_entities:
      - light.smafil
      - media_player.kitchen
      - media_player.living
    service: scene.create
  - data:
      volume_level: 0.15
    entity_id: media_player.living
    service: media_player.volume_set
  - data:
      volume_level: 0.5
    entity_id: media_player.kitchen
    service: media_player.volume_set

Second automation to restore situation:

- id: '1592952090805'
  alias: FB idle -> squeezeplayer
  description: End of calls
  trigger:
  - entity_id: sensor.phone
    from: ringing
    platform: state
    to: idle
  - entity_id: sensor.phone
    from: talking
    platform: state
    to: idle
  condition: []
  action:
  - delay: 00:00:02
  - scene: scene.before

Thanks A LOT
Nick

Sounds like there could be an issue with the squeezeplayer integration rather than your automation. Is it a custom or core integration?

Hi tom_l

Didn’t think in that direction, but that makes sense.
What’s the difference between custom <-> core integration?

It’s integrated through configuration.yaml:

media_player:
- platform: squeezebox
  host: 172.16.0.100

Nick

That would be a core integration as it is part of home assistant without having to add a custom integration.

So you can report issues for that here:

If it was a custom integration you would have had to report it on the custom integration’s repository.

1 Like

As a test, I removed the entry from my config: the integration is still functional (and visible in integrations) and apparently it didn’t have any effect on my problem.
Could it be that, by upgrading HA, I got presented the new integration and I added it as well?

I see now that through the config file it’s deprecated so I leave it like that, but where to report it then?

This reply does not particularly address your issue but I do think that your automation could be significantly simplified.
Your triggers are all from: idle
Why ?
You are interested only in what they are going to
And similarly your restore should simply be on to: idle

Make sure the options are set correctly in the configuration / intergrations / menu. If so and the issue persists:

Like most integrations that have been moved from yaml to the UI it has issues. Report it in the link I posted above, noting that it used to work when the integration was configured with yaml.

I switched it back: removed from the integrations and added in yaml but still the same behavior.

@Mutt: thanks for your suggestion and it makes sense what you say but I think I had to do it this way because in certain situations it didn’t go smooth.
Since using VoIP with multiple channels/lines, when already in a call and a 2nd call was made, the state with reduced volume was used as the state to go back to.

The issue was likely introduced when the UI configuration was added and now affects both configuration methods. If you don’t report the issue that the squeezebox playlist is no longer saved in scenes it won’t get fixed.

Of course, I just reported it.
Thanks for your help!

Edit: changed the title so others could benefit from it.

There is a bug in the squeezebox integration that prevented it from saving the whole playlist to a scene. I submitted a fix. But for Nick’s problem, I think the key is to save only the volume_level to the scene. Otherwise, you will restore the playlist back to where it was when the call started, which I don’t think is the desire behavior.

    action:
    - data_template:
      scene_id: before
      snapshot_entities:
      - light.smafil
      entities:
        media_player.kitchen:
          volume_level: {{state_attr('media_player.kitchen', 'volume_level')}}
        media_player.living:
          volume_level: {{state_attr('media_player.living', 'volume_level')}}
    service: scene.create
1 Like

Hi rajlaud, as you can see from my automation, I was not doing anything to save the playlist and when it still was working, the playlist was untouched so only the volume had to be saved & restored.

I have tried to puzzle your code back into my automation but could not get it to function.
Will have a look at it again the next days.

Tried to implement this but get error messages when checking my configuration.
I have moved things back and forth, compared examples and checked to docs but cannot get it to work.

Can anybody have a look at this automation please?

- id: '1592951986553'
  alias: FB Rings -> squeezeplayer
  description: Calling: volume down
  trigger:
  - entity_id: sensor.phone
    from: idle
    platform: state
    to: ringing
  - entity_id: sensor.phone
    from: idle
    platform: state
    to: talking
  - entity_id: sensor.phone
    from: idle
    platform: state
    to: dialing
  condition:
  - condition: state
    entity_id: media_player.living
    state: playing
  action:
    data_template:
      scene_id: before
      snapshot_entities:
        - light.smafil
        - media_player.kitchen
        - media_player.living
      entities:
        media_player.kitchen:
          volume_level: "{{ state_attr('media_player.kitchen', 'volume_level') }}"
        media_player.living:
          volume_level: "{{ state_attr('media_player.living', 'volume_level') }}"
    service: scene.create      
  - data:
      volume_level: 0.16
    entity_id: media_player.living
    service: media_player.volume_set
  - data:
      volume_level: 0.5
    entity_id: media_player.kitchen
    service: media_player.volume_set
  mode: single

Thanks A LOT!

You are missing a dash before the first data_template: in your actions.

  action:
  - data_template:

Thanks for steppin’ in Tom!
I had tried a lot of different things (YAML knowledge is very basic) and as you maybe noticed, I also had made some changes in the template but without success.
Finally, it’s indeed that dash that made it work! :+1:

But… I still have that problem of the playlist being wiped - except for 1 song - and strangely enough, it’s not the current playing song but from some time ago…

Changed the title to be more specific.

The automation does not work at all with the data_template section included.
I noticed errors in the log file, can anyone please explain what is wrong?