tesla icon indicating copy to clipboard operation
tesla copied to clipboard

Dynamic Polling Automation not working

Open ddaddy opened this issue 2 years ago • 6 comments

I am setting up the Dynamic Polling as explained here: https://github.com/alandtse/tesla/wiki/Dynamic-Polling-Frequency

When I run the action of an automation to set it to 30s I see no difference. I also get the error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'entity_id'

What exactly is the binary_sensor referred to in these lines?

action:
    - delay: '00:01:00'
    - service: tesla_custom.polling_interval
      data:
        vin: "{{ state_attr('binary_sensor.' ~ trigger.entity_id.split('.')[1].split('_')[0] ~ '_online_sensor','vin') }}"
        scan_interval: 30

I have no sensor ending with _online_sensor. Has this perhaps been renamed? I also have no entity called tesla_custom.polling_interval.

ddaddy avatar Apr 22 '24 16:04 ddaddy

You should use the name of your binary sensor (depends on the name of your integration). For my integration it is binary_sensor.model_y_online (maybe the code above is a little bit outdated).

sgriessini avatar Apr 23 '24 08:04 sgriessini

Ah ok. I guess the _sensor ending has been removed.

So I have this which seems to make the HA UI happy:

action:
  - delay: "00:01:00"
  - service: tesla_custom.polling_interval
    data:
      vin: binary_sensor.jess_online
      scan_interval: 30

ddaddy avatar Apr 23 '24 08:04 ddaddy

You have to use the VIN attribute: state_attr('binary_sensor.jess_online','vin')

sgriessini avatar Apr 23 '24 09:04 sgriessini

Ah yes, that makes sense now. Is there any way to view the current polling interval to make sure it's worked? This template just gives unknown

{{ state_attr('tesla_custom.polling_interval', 'MYVIN') }}

ddaddy avatar Apr 23 '24 09:04 ddaddy

Ah ok. I guess the _sensor ending has been removed.

So I have this which seems to make the HA UI happy:

action:
  - delay: "00:01:00"
  - service: tesla_custom.polling_interval
    data:
      vin: binary_sensor.jess_online
      scan_interval: 30

In case anyone else looks this up. This wasn't actually working as it needs to be written as"

  action:
    - service: tesla_custom.polling_interval
      data:
        vin: "{{ state_attr('binary_sensor.jess_online','vin') }}"
        scan_interval: 30

It would be good to have access to the polling interval through a sensor.

ddaddy avatar Apr 24 '24 07:04 ddaddy

I have updated the Wiki with the latest sensor names. (I was surprised it let me just edit it without a pull request!)

ddaddy avatar Apr 24 '24 09:04 ddaddy