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

0.22 vs 0.4x vs Tesla Fleet vs HA 2025.x #78

Open
dettofatto opened this issue Jan 15, 2025 · 11 comments
Open

0.22 vs 0.4x vs Tesla Fleet vs HA 2025.x #78

dettofatto opened this issue Jan 15, 2025 · 11 comments

Comments

@dettofatto
Copy link

dettofatto commented Jan 15, 2025

Hello, thank you for your magnificent work, as you might have noticed, I’m a fan of yours! I’ve attached a screenshot to show you how I’m using your Docker, which I’m currently running on version 0.22. I wanted to ask if these observations can also be applied to the newer versions.
I’m using Tesla Fleet at the same time as your tool, where Tesla Fleet is used for querying data, and your tool is used for sending commands. The Docker runs on a Raspberry Pi 4 located near the cars, and the execution time for a command is about 7 seconds. I have solar panels, and my goal is to regulate the charging process based on the sunlight.

As you can see, I’m charging two Tesla cars. The first one is on a three-phase connection (max 11kW), and the other on a single-phase connection (max 3.5kW). I’ve added numbers (in yellow) on the screenshot for reference:

Line 1 corresponds to the kW reserved for my house (I can choose manually), which is calculated as a ratio of solar production and the value read by an automation that adjusts the amperage for the two cars. In this case, I’m reserving 0.5kW for the house, the solar production is 4.63kW, and the Tesla value (number 7 in yellow) tells the automation to use 7A for (number 2 in yellow: “Tesla Mia Amperage”), which is triggered by the automation at point 8.
The other Tesla (number 4) is not using automation, and I’ve manually set it to 3A.
If the Tesla value (number 7) increases or decreases, depending on numbers 9 and 1, the amperage (number 2) also increases or decreases.
Furthermore, if I disable 8 and 5, I can manually adjust the amperage on line 2.

After this long introduction, I’ve noticed that with the newer versions, there seems to be command congestion. Often, when both Teslas are no longer at home, I need to restart the Docker, which doesn’t happen with version 0.22.

Additionally, I’ve noticed that with version 0.22, the value at point 6 in yellow on the screenshot isn’t static but instead updates dynamically. Let me explain better:
When I send the command through your Docker (e.g., 7A), the amperage slider in version 0.22 adjusts to 7. However, in version 0.4x, it needs to be updated manually.

On cloudy days, in addition to creating a constant back-and-forth of commands from the automation (which always needs to know the current charging amperage), this results in the "not-at-home" issue. With Tesla Fleet, I don’t experience this problem, and I could continue using TF along with version 0.22, but I’ve noticed that when upgrading to the new version of HA (2025.x), Tesla Fleet becomes almost unusable.

And so, here’s my final question:
Is it possible to somehow integrate or limit Tesla Fleet (which will likely be discontinued soon) and modify your project to follow a similar approach? I’m also attaching my automation.

Thank you for your support and continuous work.

screenshot ricarica

Automation (3), I've another automation for 4

alias: Ricarica Tesla Mia
description: Aumenta gli ampere di ricarica di Tesla Mia in base alla produzione di energia
triggers:
  - trigger: time_pattern
    seconds: /15
    enabled: true
  - entity_id: sensor.tesla_kw_sottratti_da_casa
    trigger: state
    enabled: true
conditions:
  - condition: device
    device_id: 930976fa5e779b9b4646ef6e4c82da50
    domain: lock
    entity_id: 01e8c773262645fc62a3a483651c08d6
    type: is_locked
  - condition: state
    entity_id: sensor.tesla_mia_charging
    state: charging
actions:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: -10000
            below: 0.6
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: sensor.tesla_mia_charger_current
                below: 2.1
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 0
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 0.6
            below: 1.32
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 2.1
                above: 1.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 2
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 1.32
            below: 1.99
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: sensor.tesla_mia_charger_current
                below: 3.1
                above: 2.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 3
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 1.99
            below: 2.64
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 4.1
                above: 3.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 4
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 2.64
            below: 3.3
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 5.1
                above: 4.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 5
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 3.3
            below: 3.96
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 6.1
                above: 5.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 6
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 3.96
            below: 4.6
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 7.1
                above: 6.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 7
          - delay:
              hours: 0
              minutes: 0
              seconds: 8
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 4.5
            below: 5.28
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 8.1
                above: 7.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 8
          - delay:
              hours: 0
              minutes: 0
              seconds: 8
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 5.28
            below: 5.94
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 9.1
                above: 8.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 9
          - delay:
              hours: 0
              minutes: 0
              seconds: 8
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 5.94
            below: 6.6
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 10.1
                above: 9.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 10
          - delay:
              hours: 0
              minutes: 0
              seconds: 8
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 6.6
            below: 7
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 13.1
                above: 12.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 13
          - delay:
              hours: 0
              minutes: 0
              seconds: 8
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 7
            below: 7.2
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 15.1
                above: 14.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 15
          - delay:
              hours: 0
              minutes: 0
              seconds: 8
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
      - conditions:
          - condition: numeric_state
            entity_id: sensor.tesla_kw_sottratti_da_casa
            above: 7.2
            below: 12
          - condition: not
            conditions:
              - condition: numeric_state
                entity_id: number.tesla_mia_charge_current
                below: 16.1
                above: 15.9
        sequence:
          - device_id: fd6deb800e11e84cd1f19c4ad77860ba
            domain: number
            entity_id: 59cc05d8fa2aedf960c9c67fb0f2c041
            type: set_value
            value: 16
          - delay:
              hours: 0
              minutes: 0
              seconds: 8
              milliseconds: 0
          - data:
              entity_id:
                - number.tesla_mia_charge_current
            action: homeassistant.update_entity
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
mode: single
@iainbullock
Copy link
Collaborator

It is a very interesting setup you have. I think many people are using this for controlling their solar / car charging. In my setup I also have a home battery, which is useful as it means I don't have to keep changing the car's charging current very often. I attempt to keep the home battery at approx 80%. Once the home battery is close to 80% it sets the car charging current to be the same as the solar production less whatever the house is using. It doesn't have to be very accurate nor update very often as the home battery will either charge a little more, or discharge a little. I don't mind as long as everything I generate ends up in the home battery or the car.

I haven't been through all your automation code, but I can comment on some of your questions / comments as follows:

  • I too have found that V0.4.x will stop working if the car is away. See this Issue where I have described how I investigated and hopefully fixed this body-controller-state: Error: failed to find a BLE device: .... tesla_ble_mqtt_core#142. In your case with 2 cars you might need to set PS_LOOP_DELAY to be even more than 60 as you have twice as much scanning to do
  • The sliders 'dynamically updating' in v0.2.x is an 'illusion'. This is because in v0.2x we couldn't read state, so it used MQTT optimistic mode (see https://www.home-assistant.io/integrations/number.mqtt ). This means whenyou make a change to an entity in HA, there is no feedback as to whether the change actually occurred, HA simply assumes it has and changes the control immediately. In 0.4.x we can read state, and HA gets feedback from the state topic. It can be very slow however, as it has to wait for the next poll to take place, or a manual forced update. You can still read the value from Tesla Fleet (or the HA built in Tesla Integration) if you wish, it will probably give better performance
  • If you send many (or maybe even just a few) commands whilst the car (or cars not sure) is away, you will cause the bluetooth device to lock up which I believe is the cause of the 'not-at-home' issue you (and others) report. Your automations should not send commands to a car which is not present. I am currently experimenting with a better way of detecting presence using the 'body-controller-state'. When I'm happy with it, I will also use it to prevent command being sent when the car is not present, which I hope will improve robustness

I'm not sure I've answered everthing but hopefully it helps in some way

@dettofatto
Copy link
Author

Thank you for your suggestions!
Only for updating you, in my case I've seen that my status is reported as away, but my cars are in my home. This issue doesn't happen with 0.22.
And for the The sliders illusion, yes I know! But I must improve my observation, because I can't explain very well the situation. When I revert to 0.4x I'll improve my observation.
Thank you!

@iainbullock
Copy link
Collaborator

I have implemented various changes in v0.4.3b-dev which is on DockerHub. Main changes are robustness improvements, see the CHANGELOG. I hope this will fix the bluetooth lock up issues see tesla-local-control/tesla_ble_mqtt_core#142

@dettofatto
Copy link
Author

dettofatto commented Jan 19, 2025

Thank you again! Your work is truly awesome.
I've read all your posts for the new dev and noticed that you've resolved all the issues I previously encountered (e.g., Bluetooth hardware hc switch, presence detection, and too many commands sent to two cars).
I'm excited to test the new dev version in the coming days! I'm also thrilled by your observations in other posts-they've made me realize I'm not so crazy after all.. :-)
May be I'll try your dev with the internal bt of my nuc, then I'll test all my other bt, only for knowing (I'm too honest, and I've all my BT adapter that I've buy on Amazon).
Thank you again.
In my case I would use two different hw and Bluetooth for each car. I'll try it.

@iainbullock
Copy link
Collaborator

iainbullock commented Jan 20, 2025

It's still dev release so it might still need more work, but I think it's getting there.

I haven't tested the feature to set the hci number - if you are able to test this would be great. Set $BLE_HCI_NUM to whatever your setup needs. e.g for most people on hci0 they would set this to 0, etc

'In my case I would use two different hw and Bluetooth for each car. I'll try it.' You should get better performance I think

@dettofatto
Copy link
Author

dettofatto commented Jan 20, 2025

It's still dev release so it might still need more work, but I think it's getting there.

I haven't tested the feature to set the hci number - if you are able to test this would be great. Set $BLE_HCI_NUM to whatever your setup needs. e.g for most people on hci0 they would set this to 0, etc

'In my case I would use two different hw and Bluetooth for each car. I'll try it.' You should get better performance I think

No... With integrated bt of my NUC is the same. Presence is ok.

Listening to MQTT
vin:5xxxble_ln:Sd7c0bC match:(4a6bbC|:1:8C:0B) presence detected
vin:5YJ presence has expired, set presence ON
Received MQTT message; topic:tesla_ble/5YJ3/config msg:read-state-charge vin:5YJ7cmd:config
read-state; calling readState()
sendBLECommand: Attempt 1/5 sending Send state command with category=charge to vin:5YJcommand:state charge
Car is not responding to bluetooth, it's probably away VIN:5Y
sendBLECommand; Retrying....
sendBLECommand: Attempt 2/5 sending Send state command with category=charge to vin:5YJcommand:state charge
Car is not responding to bluetooth, it's probably away VIN:5YJ3E
sendBLECommand; Retrying....
sendBLECommand: Attempt 3/5 sending Send state command with category=charge to vin:5YJ3Ecommand:state charge
Car is not responding to bluetooth, it's probably away VIN:5Y
sendBLECommand; Retrying....
sendBLECommand: Attempt 4/5 sending Send state command with category=charge to vin:5YJcommand:state charge
Car is not responding to bluetooth, it's probably away VIN:5YJ3
sendBLECommand; Retrying....
sendBLECommand: Attempt 5/5 sending Send state command with category=charge to vin:5YJ command:state charge
Car is not responding to bluetooth, it's probably away VIN:5YJ
sendBLECommand; Retrying....
sendBLECommand; max retries unsuccessfully trying to send command state charge to 5YJ
Received MQTT message; topic:tesla_ble/5Y/command msg:wake vin:5YJcmd:command
MQTT_PASSWORD=xxxx
# Default 5 (seconds)
#
BLE_CMD_RETRY_DELAY=3
# Default 120 (seconds)
#
PRESENCE_DETECTION_LOOP_DELAY=120
# Default 240 (seconds)
#
PRESENCE_DETECTION_TTL=240
# Your timezone
# Ref: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
#
TZ='Europe/Rome'
### Default false
#
TEMPERATURE_UNIT_FAHRENHEIT=false
### Default 48
#
MAX_CURRENT=16
### Default false
#
DEBUG=false
#
# WARNING; If you run Home Assistant, keep this true unless you know what you're doing
#
ENABLE_HA_FEATURES=true
NO_POLL_SECTIONS='climate tire-pressure closures drive'
BLE_HCI_NUM=0

@iainbullock
Copy link
Collaborator

Is this your stack.env I assume so?

In which case the last line BLE_HCI_NUM=0 set to whatever your hci number is

Or you can put it in docker-compose.yml wherever you prefer to set your Docker environment variables

@dettofatto
Copy link
Author

dettofatto commented Jan 20, 2025

I've put it in docker-compose.yml
I've edited mine previous comment.
Also I've seen that the command from NUC with HA and your docker (0.43 for tesla 5y), have some issues, because also send command to other your (0.22 for tesla LR) docker on PI4

@iainbullock
Copy link
Collaborator

I'm travelling today so can't really look at it. For the NUC what did you set BLE_HCI_NUM to? Not sure how you tell what the hci number is but it might be worth looking at this in case it's something other than 0

@dettofatto
Copy link
Author

Yes. In my case was 0 and I've set 0. Il try with another adapter.
About my slider illusion in this post, you can understand better, my opinion

#82 (comment)

@iainbullock
Copy link
Collaborator

I'll comment on #82 on that thread. Let me know how you get on with the hci number here! Thanks

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