Open chriscatuk opened 2 months ago
Possible improvements:
I don't know why the location is regularly "unavailable" but it sends null for latitude and longitude. We always have a latitude and longitude in the API response from Smart. Which is why I don't understand why it would not always be available. Is there something better than
lat: "{{ state_attr('device_tracker.smart_none', 'latitude') | default('') }}"
lon: "{{ state_attr('device_tracker.smart_none', 'longitude') | default('') }}"
to get a reliable location?
Edit 27th Aug: I updated the way to get the utc
, elevation
and is_charging
would the problem on Location unknown be due to https://github.com/DasBasti/SmartHashtag/issues/78?
yeah, I am not sure why this happens. I am looking into it but I have not found the reason why position is not updated reliably
I believe there's 2 typo's that prevented the automation to work.
action: - action: rest_command.abrp elevation: "{{ state_attr('device_tracker.smart_none', 'altitude').value | default('') }}") ```yaml action: - service: rest_command.abrp elevation: "{{ state_attr('device_tracker.smart_none', 'altitude').value | default('') }}"
I believe there's 2 typo's that prevented the automation to work.
action: - action: rest_command.abrp elevation: "{{ state_attr('device_tracker.smart_none', 'altitude').value | default('') }}")
action: - service: rest_command.abrp elevation: "{{ state_attr('device_tracker.smart_none', 'altitude').value | default('') }}"
I agree for Elevation, I transformed what I really have on my HASS and made a typo:
elevation: >-
{{ state_attr('device_tracker.smart_none', 'altitude').value |
default('') }}
but for
action:
- action: rest_command.abrp
it's a strict copy/past of the automation I'm using successfully on 2 different HASS and it works for me.
what does fail for you? or is it an improvement suggestion?
It didn't work for me, as HA see the rest command as a service, so the action needed is a service call.
Found another issue with the power: ABRP expects kW and the smart is reporting W, so I divided the value by 1000.
I was reading 6840kW in ABRP and didn't notice how wrong it was. Thanks for noticing! And sorry for the mistake
I also wanted to test with service
like you said, but the format of the YAML changed in HASS 2024.10. So this readme will need an update anyway.
I added /1000
and I'm testing. I'll share my new config in a following comment after it worked.
this is what worked for me:
alias: ABRP update
description: ""
triggers:
- entity_id:
- sensor.smart_last_update
trigger: state
conditions: []
actions:
- action: rest_command.abrp
data:
token: 99999999-aaaa-aaaa-bbbb-eeeeeeeeee # generated for each car in ABRP app
api_key: 8888888-2222-44444-bbbb-333333333 # obtained from contact@iternio.com , see https://documenter.getpostman.com/view/7396339/SWTK5a8w
utc: "{{ as_timestamp(now()) | int }}"
soc: >-
{{ states('sensor.smart_battery', rounded=False, with_unit=False) |
default('') }}
soh: 100
power: >
{% if states('sensor.smart_charging_power', rounded=False,
with_unit=False) | default(0) | float > 0 %}
-{{ states('sensor.smart_charging_power', rounded=False, with_unit=False) | int / 1000 }}
{% endif %}
speed: ""
lat: "{{ state_attr('device_tracker.smart_none', 'latitude') | default('') }}"
lon: "{{ state_attr('device_tracker.smart_none', 'longitude') | default('') }}"
elevation: >-
{{ state_attr('device_tracker.smart_none', 'altitude').value |
default('') }}
is_charging: >
{% if states('sensor.smart_charging_status') == 'charging' or
states('sensor.smart_charging_status') == 'DC charging' %}
1
{% else %}
0
{% endif %}
is_dcfc: |
{% if states('sensor.smart_charging_status') == 'DC charging' %}
1
{% else %}
0
{% endif %}
is_parked: "{{ states('sensor.smart_electric_park_brake_status') | default(0) }}"
ext_temp: >-
{{ states('sensor.smart_exterior_temperature', rounded=False,
with_unit=False) | default('') }}
odometer: >-
{{ states('sensor.smart_odometer', rounded=False, with_unit=False) |
default('') }}
est_battery_range: >-
{{ states('sensor.smart_range', rounded=False, with_unit=False) |
default('') }}
mode: single
what do you think? they changed the list of actions in 2024.10. So I wonder if it's still a service for you?
I could successfully setup an automation in Home Assistant to send an update to ABRP each Time the last_update date changes.
Below is my first attempt, it worked already:
then in my configuration.yaml this is the rest_command:
Do you think of a way to integrate it directly in this integration? Or a Readme maybe to share the way of doing it each of us?
edit: updated the Values with my latest more elaborated version