Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teslemetry command failed, An error occurred while processing the request. #82

Open
3 tasks done
MatthewGrech opened this issue May 13, 2024 · 5 comments
Open
3 tasks done

Comments

@MatthewGrech
Copy link

Checklist

  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of any previous issues..

Describe the issue

When triggering an automation i am getting the following error in the logs.

Error while executing automation automation.tesla_smart_charge_charge_on_solar_power2: Teslemetry command failed, An error occurred while processing the request.
Error while executing automation automation.tesla_smart_charge_charge_on_solar_power2: is_charging

Reproduction steps

...

Debug logs

No response

@Bre77
Copy link
Contributor

Bre77 commented May 13, 2024

What commands do you have in that automation? Unless I know whats itside of it I wont be able to troubleshoot this one any futher.

@MatthewGrech
Copy link
Author

`alias: "[Tesla Smart Charge] Charge on solar power"
description: ""
trigger:
  - platform: state
    entity_id: sensor.power_grid_usage
condition:
  - condition: template
    value_template: |
      {{ now() - this.attributes.last_triggered > timedelta(seconds=10) }}
  - condition: state
    entity_id: input_boolean.smart_charge
    state: "on"
  - condition: state
    entity_id: binary_sensor.tesla_charge_cable
    state: "on"
  - condition: state
    entity_id: device_tracker.tesla_location
    state: home
action:
  - variables:
      min_charging_amps: 1
      minimum_start_amps: 2
      max_charging_amps: 16
      current_charging_amps: "{{ states('number.tesla_charge_current') | int }}"
      spare_energy: "{{ states('sensor.power_grid_usage') | float }}"
      grid_voltage: "{{ 240 | float * 3 }}"
      spare_amps: "{{ (spare_energy / grid_voltage) | round(0, 'floor') | int }}"
      new_charge_amps: "{{ (current_charging_amps + spare_amps) | int }}"
      charge_limit: "{{ states('number.tesla_charge_limit_2') | int }}"
      battery_level: "{{ states('sensor.tesla_battery_level') | int }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ spare_amps >= minimum_start_amps }}"
          - condition: state
            entity_id: switch.tesla_charge
            state: "off"
          - condition: template
            value_template: "{{ charge_limit > battery_level }}"
        sequence:
          - service: logbook.log
            data:
              name: "[Tesla Smart Charge]"
              message: >-
                Charger is off and we have {{ spare_amps }} spare amps.
                Attempting to start charge
          - choose:
              - conditions:
                  - condition: state
                    entity_id: timer.turn_off_car_charger
                    state: active
                sequence:
                  - service: timer.cancel
                    target:
                      entity_id: timer.turn_off_car_charger
                    data: {}
          - service: number.set_value
            target:
              entity_id: number.tesla_charge_current
            data:
              value: "{{ spare_amps }}"
          - service: switch.turn_on
            target:
              entity_id: switch.tesla_charge
            data: {}
      - conditions:
          - condition: state
            entity_id: switch.tesla_charge
            state: "on"
          - condition: template
            value_template: "{{ spare_amps > 0 }}"
          - condition: template
            value_template: "{{ current_charging_amps < max_charging_amps }}"
        sequence:
          - service: logbook.log
            data:
              name: "[Tesla Smart Charge]"
              message: >-
                Charger is on and we have {{ spare_amps }} spare amps. Already
                at {{ current_charging_amps }} amps. Attempting to increase
                charge rate to {{ (current_charging_amps + spare_amps) | int }}
                amps
          - choose:
              - conditions:
                  - condition: state
                    entity_id: timer.turn_off_car_charger
                    state: active
                sequence:
                  - service: timer.cancel
                    target:
                      entity_id: timer.turn_off_car_charger
                    data: {}
          - service: number.set_value
            target:
              entity_id: number.tesla_charge_current
            data:
              value: "{{ [max_charging_amps, new_charge_amps] | min }}"
      - conditions:
          - condition: state
            entity_id: switch.tesla_charge
            state: "on"
          - condition: template
            value_template: "{{ new_charge_amps < min_charging_amps }}"
        sequence:
          - service: logbook.log
            data:
              name: "[Tesla Smart Charge]"
              message: >-
                Charger is on and we don't have enough juice to even charge at
                {{ min_charging_amps }}A. Turning off charger in 5 minutes.
                (new_charge:{{ new_charge_amps }}A < min_charging:{{
                min_charging_amps }}A) (current_charging:{{
                current_charging_amps }}A + spare:{{ spare_amps }}A) (power
                out:{{ spare_energy }})
          - service: number.set_value
            target:
              entity_id: number.tesla_charge_current
            data:
              value: "{{ min_charging_amps }}"
          - choose:
              - conditions:
                  - condition: or
                    conditions:
                      - condition: state
                        entity_id: timer.turn_off_car_charger
                        state: idle
                      - condition: state
                        entity_id: timer.turn_off_car_charger
                        state: paused
                sequence:
                  - service: timer.start
                    target:
                      entity_id: timer.turn_off_car_charger
                    data:
                      duration: "00:05:02"
      - conditions:
          - condition: state
            entity_id: switch.tesla_charge
            state: "on"
          - condition: template
            value_template: "{{ spare_amps < 0 }}"
        sequence:
          - service: logbook.log
            data:
              name: "[Tesla Smart Charge]"
              message: >-
                Charger is on and we are using {{ spare_amps }} too many amps.
                Attempting to decrease charge rate to:{{ [min_charging_amps,
                new_charge_amps] | max }}
          - choose:
              - conditions:
                  - condition: state
                    entity_id: timer.turn_off_car_charger
                    state: active
                sequence:
                  - service: timer.cancel
                    target:
                      entity_id: timer.turn_off_car_charger
                    data: {}
          - service: number.set_value
            target:
              entity_id: number.tesla_charge_current
            data:
              value: "{{ [min_charging_amps, new_charge_amps] | max }}"
    default: null
mode: single
trace:
  stored_traces: 30
`

@MatthewGrech
Copy link
Author

This is another example

alias: Tesla set polling time short at sunrise
description: We adjust the Polling Interval down at sunrise
trigger:
  - platform: sun
    event: sunrise
condition:
  - condition: state
    entity_id: binary_sensor.tesla_charger
    state: "on"
action:
  - service: tesla_custom.polling_interval
    data:
      vin: "{{ state_attr('binary_sensor.tesla_online','vin') }}"
      scan_interval: 30

@MatthewGrech
Copy link
Author

A couple others if you need that are failing. All are separate automations but for the same purpose (Charge on solar)

id: '1715219439274'
alias: '[Tesla Smart Charge] Turning off car charger'
description: ''
trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.turn_off_car_charger
condition: []
action:
  - service: switch.turn_off
    target:
      entity_id: switch.tesla_charge
    data: {}
mode: single

Error message through trace

Executed: May 13, 2024 at 4:12:44 PM
Error: Teslemetry command failed, An error occurred while processing the request.
Result:
params:
  domain: switch
  service: turn_off
  service_data: {}
  target:
    entity_id:
      - switch.tesla_charge
running_script: false

@Bre77
Copy link
Contributor

Bre77 commented May 13, 2024

So right off the bat, turning charging on or off when it's already on or off used to trigger an error. The most recent release I did no longer does this, however there may be other services that need this treatment.

As a general rule if you want an automation to continue when an error has occurred, add continue_on_error: true to the service calls.

However I'll need to figure out which call is throwing the unknown response error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants