#actions not allowed for some reason

1 messages ยท Page 1 of 1 (latest)

supple seal
#

hey all, i am struggling (and i think i'm just being stupid)

#
template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecast
        data:
          type: hourly
        target:
          entity_id: weather.home
        response_variable: hourly
    sensor:
      - name: Weather Forecast Hourly
        unique_id: weather_forecast_hourly
        state: "{{ now().isoformat() }}"
        attributes:
          forecast: "{{ hourly.forecast }}"
#

this is what's in the manual... however, when i paste literally this in my templates.yaml file

#

it says: action not allowed

final dagger
#

you need to remove the template: line if you just paste that in templates.yaml

supple seal
#

i iknow that ๐Ÿ˜‰

final dagger
#

and then presumably have template: !include templates.yaml

#

๐Ÿคท

supple seal
#

i have that , indeed ๐Ÿ˜‰

final dagger
#

just going on what you said

supple seal
#

so I pasted the "paste" without template:

final dagger
#

my guess is that you're using an old version of HA

supple seal
#

it says; property action is not allowed

final dagger
#

what is "it"?

supple seal
#

nope, latest and greatest ๐Ÿ™‚

#

studio code server

final dagger
#

ignore that

#

check your config

#

that is not HA, and it usually lags changes in HA

supple seal
#

hmm.... i will try again, with my actual goal ๐Ÿ™‚

#

is there a way i can manually trigger this?:

#
- trigger:
    - platform: time_pattern
      hours: /1
  action:
    - service: calendar.list_events
      target:
        entity_id: calendar.family
      response_variable: agenda
  sensor:
    - name: agenda_items
      unique_id: agenda_items
      state: "{{ agenda.events | count() }}"
      attributes:
        scheduled_events: "{{ agenda.events }}"
#

if not, debugging will be a pita ๐Ÿ™‚

final dagger
#

yes, with homeassistant.update_entity

supple seal
#

check! thanks

#

hmm.... how do i do that?

final dagger
#

it's a normal service call

#
service: homeassistant.update_entity
entity_id: sensor.agenda_items
supple seal
#

i'll look for it in developer tools

#

it doesn't seem to work as expected ๐Ÿ˜ฆ

#
- trigger:
    - platform: time_pattern
      hours: /1
  action:
    - service: calendar.list_events
      data:
        duration:
          hours: 180
      target:
        entity_id: calendar.family
      response_variable: agenda
  sensor:
    - name: agenda_items
      unique_id: agenda_items
      state: "{{ agenda.events | count() }}"
      attributes:
        scheduled_events: "{{ agenda.events }}"
#

i changed it from 48 hours to 180, but the value stays the same...

#

i would have expected more entries

final dagger
#

ok

supple seal
#

if i change it to 10 hours... so should only have 1 entry... it's still 6 (what was correct for 48 hours

#

any clue?

final dagger
#

no

#

I think there's actually a bug there

#

if I call homeassistant.update_entity on a template sensor with a trigger defined, I get an error in the log:

- trigger:
    platform: time_pattern
    hours: /1
  sensor:
  - name: action_test_trigger
    state: "{{ now() }}"

- sensor:
  - name: action_test_no_trigger
    state: "{{ now() }}"

Call homeassistant.update_entity on the first one and I get

2023-10-21 12:21:30.851 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.action_test_trigger fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 732, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 991, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 507, in async_update
    await self.coordinator.async_request_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 240, in async_request_refresh
    await self._debounced_refresh.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 93, in async_call
    await task
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 266, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 356, in _async_refresh
    raise err
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 245, in _async_update_data
    raise NotImplementedError("Update method not implemented")
NotImplementedError: Update method not implemented
#

second one works fine

supple seal
#

hmm.... thanks

supple seal
#

ahm... i'm lost...

#
- trigger:
    - platform: time_pattern
      hours: /3
  action:
    - service: weather.get_forecast
      data:
        type: daily
      target:
        entity_id: weather.openweathermap
      response_variable: weathertoday
  sensor:
    - name: "today maximum temperature"
      unique_id: today_maximum_temperature
      state: "{{ weathertoday.forecast[0].temperature | float}}"
    - name: "today precipitation"
      unique_id: today_precipitation
      state: "{{ weathertoday.forecast[0].precipitation | float }}"
#

can someone tell me what's wrong with this?

#

i really don't get it

#

i tried... for hours and nowhere an example to be found

#

this shouldn't be hard, but i failed...

#

should it be: state_attr('weathertoday.forecast[0]', 'temperature') ? i tried that too...

supple seal
#

{{ state_attr('weathertoday', 'forecast')[0].temperature }}

#

also fails