Giter VIP home page Giter VIP logo

Comments (5)

Bre77 avatar Bre77 commented on July 25, 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.

from hass-teslemetry.

MatthewGrech avatar MatthewGrech commented on July 25, 2024
`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
`

from hass-teslemetry.

MatthewGrech avatar MatthewGrech commented on July 25, 2024

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

from hass-teslemetry.

MatthewGrech avatar MatthewGrech commented on July 25, 2024

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

from hass-teslemetry.

Bre77 avatar Bre77 commented on July 25, 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.

from hass-teslemetry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.