Barma-lej / halandroid

Worx Landroid package for Home Assistant based on Landroid Cloud by @MTrab
MIT License
112 stars 49 forks source link

Automation errors #35

Closed jone9618 closed 2 years ago

jone9618 commented 2 years ago

Hello

I installed this package a few days ago - just after I upgraded to HA 2021.11.

All works well - great work. Only issue is that I get the following error on the card when displaying the automations:

image

I have used the landroid.yaml and landroid_en.yaml from github.

When I try to run either of the two "missing" automations from the automations dashboard in HA I have errors returned in my log, such as:

Error while executing automation automation.mower_status_notificaion: Error rendering data template: UndefinedError: 'dict object' has no attribute 'from_state'
15:38:19 – (ERROR) Automation
Mower status notification: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'from_state'
15:38:19 – (ERROR) Automation
Template variable error: 'dict object' has no attribute 'from_state' when rendering '{{ trigger.from_state.state }} -> {{ trigger.to_state.state }} - {{ states('sensor.date_time') }}'
15:38:19 – (ERROR) helpers/template.py - message first occurred at 15:38:18 and shows up 2 times
Error while executing automation automation.mower_error_notificaion: Error rendering data template: UndefinedError: 'dict object' has no attribute 'from_state'
15:38:18 – (ERROR) Automation
Mower error notification: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'from_state'
15:38:18 – (ERROR) Automation

This is the section of my landroid.yaml which defines the two automations:

# Automations #######################################################
automation:
  - id: mower_notify_status
    alias: Mower status notificaion
    initial_state: false
    trigger:
      - platform: state
        entity_id: sensor.landroid_mower_status

    condition:
      - condition: template
        value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"

    action:
      - service: persistent_notification.create
        data:
          title: 🏎️ Lanroid M500
          message: "{{ trigger.from_state.state }} -> {{ trigger.to_state.state }} - {{ states('sensor.date_time') }}"

  - id: mower_notify_error
    alias: Mower error notificaion
    initial_state: true
    trigger:
      - platform: state
        entity_id: sensor.landroid_mower_error

    condition:
      - condition: template
        value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"

    action:
      - service: persistent_notification.create
        data:
          title: 🏎️ Lanroid M500
          message: "{{ trigger.from_state.state }} -> {{ trigger.to_state.state }} - {{ states('sensor.date_time') }}"

(as an aside - there is a typo in the alias of both automations - "notificaion" instead of of "notification")

Am I doing something wrong?

Barma-lej commented 2 years ago

Copy these lines from your Lovelace:

        - type: custom:fold-entity-row
          head:
            type: section
            label: Automatisierungen
          entities:
            - entity: automation.mower_notify_error
            - entity: automation.mower_notify_status
            - entity: automation.mower_sync_values

and past here

jone9618 commented 2 years ago

These are the lines from my lovelace:

    - type: custom:fold-entity-row
      head:
        type: section
        label: Automations
      entities:
        - entity: automation.mower_notify_error
        - entity: automation.mower_notify_status
        - entity: automation.mower_sync_values
Barma-lej commented 2 years ago

I checked package again andI cannot confirm the error. Could you post your landroid.yaml, landroid_en.yaml and lovelace card?

timvdsm commented 2 years ago

I have the same problem, was there any root-cause know? Many thanks for your hard work!

Barma-lej commented 2 years ago

Change aliases to

  - id: mower_notify_status
    alias: Mower Notify Status

and

  - id: mower_notify_error
    alias: Mower Notify Error
automation:
  - id: mower_notify_status
    alias: Mower Notify Status
    initial_state: false
    trigger:
      - platform: state
        entity_id: sensor.landroid_mower_status

    condition:
      - condition: template
        value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"

    action:
      - service: persistent_notification.create
        data:
          title: 🏎️ Lanroid M500
          message: "{{ trigger.from_state.state }} -> {{ trigger.to_state.state }} - {{ states('sensor.date_time') }}"

  - id: mower_notify_error
    alias: Mower Notify Error
    initial_state: true
    trigger:
      - platform: state
        entity_id: sensor.landroid_mower_error

    condition:
      - condition: template
        value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"

    action:
      - service: persistent_notification.create
        data:
          title: 🏎️ Lanroid M500
          message: "{{ trigger.from_state.state }} -> {{ trigger.to_state.state }} - {{ states('sensor.date_time') }}"
jone9618 commented 2 years ago

Hello

I’m sorry it has taken me so long to respond. This is still not working. Here are the three files (I have amended the Landroid.yaml file as you suggested om 13.12.21, but with no success.

Landroid.yaml: ´´´

Worx Landroid (M500 WR141E) package

https://github.com/Barma-lej/halandroid

Based on Landroid Cloud by @MTrab

https://github.com/MTrab/landroid_cloud

Cloud

landroid_cloud: email: !secret mower_mail password: !secret mower_pass

type: landxcape

type: kress

Recorder

recorder: exclude: entities:

Swithes

  #- swith.mower_mowing
  #- swith.mower_home
  #- swith.mower_edgecut
  #- swith.mower_partymode
  #- swith.mower_lock

# Sensors ###############
  - sensor.mower_ip
  #- sensor.mower_bladetime
  #- sensor.mower_current bladetime
  #- sensor.mower_totaltime
  #- sensor.mower_distance
  #- sensor.mower_lastupdate
  #- sensor.mower_wifi
  #- sensor.mower_yaw
  #- sensor.mower_roll
  #- sensor.mower_pitch

# Input selects #########
  - input_select.mower_zone

# Input numbers #########
  - input_number.mower_raindelay
  - input_number.mower_timeextension
  - input_number.mower_zone0_distance
  - input_number.mower_zone1_distance
  - input_number.mower_zone2_distance
  - input_number.mower_zone3_distance
  - input_number.mower_zone0_probability
  - input_number.mower_zone1_probability
  - input_number.mower_zone2_probability
  - input_number.mower_zone3_probability

# Input booleans ########
  - input_boolean.mower_sched_settings
  - input_boolean.mower_info_toggle
  - input_boolean.mower_zone_enable
  - input_boolean.mower_view_config
  - input_boolean.mower_view_setzones

# Automations ######
  - automation.mower_notify_status
  - automation.mower_notify_error
  - automation.mower_sync_values
  - automation.mower_views_switch

# Scripts ##########
  - script.mower_set_config
  - script.mower_setzone
  - script.mower_setzones
  - script.mower_views_toggle

Logbook

logbook: exclude: entities:

Swithes

  #- swith.mower_mowing
  #- swith.mower_home
  #- swith.mower_edgecut
  #- swith.mower_partymode
  #- swith.mower_lock

# Sensors ###############
  - sensor.mower_ip
  #- sensor.mower_bladetime
  #- sensor.mower_current bladetime
  #- sensor.mower_totaltime
  #- sensor.mower_distance
  #- sensor.mower_lastupdate
  #- sensor.mower_wifi
  #- sensor.mower_yaw
  #- sensor.mower_roll
  #- sensor.mower_pitch

# Input selects #########
  - input_select.mower_zone

# Input numbers #########
  - input_number.mower_raindelay
  - input_number.mower_timeextension
  - input_number.mower_zone0_distance
  - input_number.mower_zone1_distance
  - input_number.mower_zone2_distance
  - input_number.mower_zone3_distance
  - input_number.mower_zone0_probability
  - input_number.mower_zone1_probability
  - input_number.mower_zone2_probability
  - input_number.mower_zone3_probability

# Input booleans ########
  - input_boolean.mower_sched_settings
  - input_boolean.mower_info_toggle
  - input_boolean.mower_zone_enable
  - input_boolean.mower_view_config
  - input_boolean.mower_view_setzones

# Automations ######
  - automation.mower_notify_status
  - automation.mower_notify_error
  - automation.mower_sync_values
  - automation.mower_views_switch

# Scripts ##########
  - script.mower_set_config
  - script.mower_setzone
  - script.mower_setzones
  - script.mower_views_toggle

Switch

switch:

Sensor

sensor.landroid_mower_battery

sensor.landroid_mower_error

sensor.landroid_mower_status

template: sensor:

Info

- name: Mower IP
  unique_id: mower_ip
  state: !secret mower_ip
  icon: mdi:ip-network

Status

- name: Mower bladetime
  unique_id: mower_bladetime
  state: "{{ state_attr('sensor.landroid_mower_status', 'total_blade_time') }}"
  icon: mdi:fan
  unit_of_measurement: "min"
  attributes:
    time_formatted: >
      {% set t = state_attr("sensor.landroid_mower_status", "total_blade_time") | int %}
      {% if t != 0 %}
        {{ "%0d Tg. %0.02d Std. %0.02d Min." | format(t // 1440, ((t % 1440) // 60), t % 60) }}
      {%- else -%}
        {{ '0 min' }}
      {% endif %}

- name: Mower current bladetime
  unique_id: mower_current_bladetime
  state: "{{ state_attr('sensor.landroid_mower_status', 'current_blade_time') }}"
  icon: mdi:fan
  unit_of_measurement: "min"
  attributes:
    time_formatted: >
      {% set t = state_attr("sensor.landroid_mower_status", "current_blade_time") | int %}
      {% if t != 0 %}
        {{ "%0d Tg. %0.02d Std. %0.02d Min." | format(t // 1440, ((t % 1440) // 60), t % 60) }}
      {%- else -%}
        {{ '0 min' }}
      {% endif %}

- name: Mower totaltime
  unique_id: mower_totaltime
  state: "{{ state_attr('sensor.landroid_mower_status', 'work_time') }}"
  icon: mdi:bus-clock
  unit_of_measurement: "min"
  attributes:
    time_formatted: >
      {% set t = state_attr("sensor.landroid_mower_status", "work_time") | int %}
      {% if t != 0 %}
        {{ "%0d Tg. %0.02d Std. %0.02d Min." | format(t // 1440, ((t % 1440) // 60), t % 60) }}
      {%- else -%}
        {{ '0 min' }}
      {% endif %}

- name: Mower distance
  unique_id: mower_distance
  state: "{{ (state_attr('sensor.landroid_mower_status', 'distance') | float) / 1000 }}"
  icon: mdi:map-marker-distance
  unit_of_measurement: "km"

- name: Mower lastupdate
  unique_id: mower_lastupdate
  state: "{{ as_timestamp(strptime( state_attr('sensor.landroid_mower_status', 'last_update'), '%H:%M:%S %d/%m/%Y')) | timestamp_custom('%d.%m.%Y %H:%M:%S') }}"
  icon: mdi:clock

- name: Mower WIFI
  unique_id: mower_wifi
  state: "{{ state_attr('sensor.landroid_mower_status', 'rssi') }}"
  device_class: signal_strength
  unit_of_measurement: "dBm"
  icon: >-
    {% set strength = state_attr("sensor.landroid_mower_status", "rssi") | float -%}
    {%- if strength > -56 -%}mdi:wifi-strength-4
    {% elif strength > -67 -%}mdi:wifi-strength-3
    {% elif strength > -78 -%}mdi:wifi-strength-2
    {% elif strength > -89 -%}mdi:wifi-strength-1
    {%- else -%}mdi:wifi-strength-outline
    {%- endif %}
  # -55 or higher: 4 bars
  # -56 to -66: 3 bars
  # -67 to -77: 2 bars
  # -78 to -88: 1 bar
  # -89 or lower: 0 bars

- name: Mower yaw
  unique_id: mower_yaw
  state: "{{ state_attr('sensor.landroid_mower_status', 'yaw') }}"
  icon: mdi:axis-z-rotate-clockwise
  unit_of_measurement: "°"

- name: Mower roll
  unique_id: mower_roll
  state: "{{ state_attr('sensor.landroid_mower_status', 'roll') }}"
  icon: mdi:axis-x-rotate-clockwise
  unit_of_measurement: "°"

- name: Mower pitch
  unique_id: mower_pitch
  state: "{{ state_attr('sensor.landroid_mower_status', 'pitch') }}"
  icon: mdi:seat-flat-angled
  unit_of_measurement: "°"

Input Select

input_select: mower_zone: name: Mower zone initial: "0" options:

Input Number

input_number: mower_raindelay: name: Rain delay initial: 150 min: 0 max: 300 step: 30 unit_of_measurement: "min" icon: mdi:weather-lightning-rainy

mower_timeextension: name: Time extension initial: 0 min: -100 max: 100 step: 10 unit_of_measurement: "%" icon: mdi:clock-out

Multizone

mower_zone0_distance: name: "Zone 0: Distance" initial: 0 min: 0 max: 1000 step: 1 unit_of_measurement: "m" icon: mdi:numeric-0-box-outline mower_zone1_distance: name: "Zone 1: Distance" initial: 0 min: 0 max: 1000 step: 1 unit_of_measurement: "m" icon: mdi:numeric-1-box-outline mower_zone2_distance: name: "Zone 2: Distance" initial: 0 min: 0 max: 1000 step: 1 unit_of_measurement: "m" icon: mdi:numeric-2-box-outline mower_zone3_distance: name: "Zone 3: Distance" initial: 0 min: 0 max: 1000 step: 1 unit_of_measurement: "m" icon: mdi:numeric-3-box-outline

mower_zone0_probability: name: "Zone 0: Probability" initial: 0 min: 0 max: 100 step: 10 unit_of_measurement: "%" icon: mdi:numeric-0-circle-outline mower_zone1_probability: name: "Zone 1: Probability" initial: 0 min: 0 max: 100 step: 10 unit_of_measurement: "%" icon: mdi:numeric-1-circle-outline mower_zone2_probability: name: "Zone 2: Probability" initial: 0 min: 0 max: 100 step: 10 unit_of_measurement: "%" icon: mdi:numeric-2-circle-outline mower_zone3_probability: name: "Zone 3: Probability" initial: 0 min: 0 max: 100 step: 10 unit_of_measurement: "%" icon: mdi:numeric-3-circle-outline

Input Boolean

input_boolean:

Booleans for Lovelace

mower_sched_settings: name: Scheduler settings initial: false icon: mdi:timer

mower_info_toggle: name: Info toggle initial: false icon: mdi:information

mower_zone_enable: name: Enable multizone initial: false icon: mdi:vector-difference

Booleans for views in Lovelace

mower_view_config: name: Configuration icon: mdi:tools mower_view_setzones: name: Multizone icon: mdi:vector-difference

Automations

automation:

Scripts

Services

landroid_cloud.start

landroid_cloud.home

landroid_cloud.pause

landroid_cloud.configure landroid_cloud.config (can be used to set rain delay and time extension)

landroid_cloud.partymode (if a partymode capable device was found)

landroid_cloud.setzone

landroid_cloud.lock

landroid_cloud.restart

landroid_cloud.edgecut (only for models with the function available in the app)

script: mower_set_config: alias: Mower set rain delay and time extension sequence: service: landroid_cloud.config data: id: "{{ state_attr('sensor.landroid_mower_status','id') }}" raindelay: "{{ states('input_number.mower_raindelay') | int }}" timeextension: "{{ states('input_number.mower_timeextension') | int }}"

mower_setzone: alias: Mower set mowing zone mode: restart sequence:

Scripts

script.mower_set_config:
  friendly_name: Apply settings
  icon: mdi:content-save-settings

script.mower_setzone:
  friendly_name: Zone selection
  icon: mdi:vector-difference

script.mower_setzones:
  friendly_name: Apply multizone
  icon: mdi:content-save-settings

script.mower_views_toggle:
  friendly_name: Toggle tabs
  icon: mdi:tab

´´´ Lovelace card: ´´´ type: vertical-stack cards:

Thanks

Barma-lej commented 2 years ago

What are your automation.mower * in the Developer Tools - States?

jone9618 commented 2 years ago

automation.mower_error_notificaion http://homeassistant:8123/developer-tools/state

Mower Notify Error

on

last_triggered: 2021-11-05T15:44:57.381892+00:00 mode: single current: 0 id: mower_notify_error friendly_name: Mower Notify Error

automation.mower_status_notificaion http://homeassistant:8123/developer-tools/state

Mower Notify Status

off

last_triggered: 2021-11-05T15:44:58.516757+00:00 mode: single current: 0 id: mower_notify_status friendly_name: Mower Notify Status

automation.mower_sync_values http://homeassistant:8123/developer-tools/state

Data synchronization

on

last_triggered: 2022-01-01T22:20:37.427939+00:00 mode: single current: 0 id: mower_sync_values friendly_name: Data synchronization icon: mdi:sync

(note the mower has been put away for the winter, so not in use at the moment)

From: Barma-lej @.> Sent: 01 January 2022 22:57 To: Barma-lej/halandroid @.> Cc: jone9618 @.>; Author @.> Subject: Re: [Barma-lej/halandroid] Automation errors (Issue #35)

What are your automation.mower * in the _Developer Tools - States`?

— Reply to this email directly, view it on GitHub https://github.com/Barma-lej/halandroid/issues/35#issuecomment-1003631508 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AUEMJJGDKHLF6UPIX4GIMWTUT6BEBANCNFSM5HOFB2QA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AUEMJJHBRO5MTRSTDOB2S2TUT6BEBA5CNFSM5HOFB2QKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHPJDHFA.gif Message ID: @. @.> >

Barma-lej commented 2 years ago

You have three automations for mower

Rename these two

to

or change in your lovelace card these lines

        - type: custom:fold-entity-row
          head:
            type: section
            label: Automations
          entities:
            - entity: automation.mower_notify_error
            - entity: automation.mower_notify_status
            - entity: automation.mower_sync_values

to

        - type: custom:fold-entity-row
          head:
            type: section
            label: Automations
          entities:
            - entity: automation.mower_error_notificaion
            - entity: automation.mower_status_notificaion
            - entity: automation.mower_sync_values
jone9618 commented 2 years ago

Thank you so much. That did it. I changed the names of the automation entities from automation.mower_error_notificaion and automation.mower_status_notificaion to automation.mower_notify_error and automation.mower_notify_status.

Thank you once again.

From: Barma-lej @.> Sent: 03 January 2022 18:50 To: Barma-lej/halandroid @.> Cc: jone9618 @.>; Author @.> Subject: Re: [Barma-lej/halandroid] Automation errors (Issue #35)

You have three automations for mower

Rename these two

to

or change in your lovelace card these lines

    - type: custom:fold-entity-row
      head:
        type: section
        label: Automations
      entities:
        - entity: automation.mower_notify_error
        - entity: automation.mower_notify_status
        - entity: automation.mower_sync_values

to

    - type: custom:fold-entity-row
      head:
        type: section
        label: Automations
      entities:
        - entity: automation.mower_error_notificaion
        - entity: automation.mower_status_notificaion
        - entity: automation.mower_sync_values

— Reply to this email directly, view it on GitHub https://github.com/Barma-lej/halandroid/issues/35#issuecomment-1004286523 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AUEMJJAEFF42JUD4CNVP3P3UUHVW7ANCNFSM5HOFB2QA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AUEMJJDLL5NWFSK3W4T4WGDUUHVW7A5CNFSM5HOFB2QKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHPODEOY.gif Message ID: @. @.> >