Closed broodro0ster closed 1 year ago
I found the issue. It's has nothing to do with the battery, but with my grid sensor. I have a digital power meter and I can view the export/import via my P1 meter. The sensor value is seen as string instead of int. You don't have this issue since you are using a template sensor which is already int. I made it working by replacing "grid_power_net" by "states(grid_power_net) | int". Would be nice if you could update the blueprint. I'm guessing that other with a grid sensor will run into the same issue.
Sorry for the late response. Been quite busy with family.
The current code already has this taking default value zero if it cannot be converted.
states(grid_power_net) | float(0)
That should have worked for you. Not sure why you had to pipe it to int instead of float?
No problem. I modified the script and took out the home battery parameters and now it works for me. I'm not sure what the exact error was anymore that I ran into, but I'll try blueprint again when I have some time and report back.
hi i have the same issue, with version downloaded today. I have a sensor from my inverter with the correct negative and positive values in W. sensor.deye_inverter_sun12k_total_grid_power_2
@broodro0ster can you help me with what and where i must replace to get it working?
hi i have the same issue, with version downloaded today. I have a sensor from my inverter with the correct negative and positive values in W. sensor.deye_inverter_sun12k_total_grid_power_2
@broodro0ster can you help me with what and where i must replace to get it working?
This is the modified blueprint I'm using for now, but it's kinda a quick and dirty hack with my limited skills: https://pastebin.com/wEnmbD2j I would be better to fix the original blueprint, but I haven't had the time to try it again.
My version works, but I've seen it crashing from time to time with errno -3. I haven't figured out what's causing it, but I'm guessing it's related to a timeout from my grid meter API or the Tesla API since it usually works fine for 3-6 hours and then suddenly it stops with that error.
Thank you very much! I will try to take a look at it.
Are you using a battery in your PV system?
Thank you very much! I will try to take a look at it.
Are you using a battery in your PV system?
No, I don't have a home battery. I've removed the home battery from the blueprint I shared with you.
If you don't have a home battery, just leave the default value for the home battery selection. It will be ignored by the script.
@praun, please check the log and trace, it should give you a more info about the cause of error.
@praun, please check the log and trace, it should give you a more info about the cause of error.
I have a home battery. the error i get is exactly the same as broodrooster described:
Error: TypeError: '>' not supported between instances of 'int' and 'str'
as far as i can see the entities i use, give a number as output, so i cannot find the reason for the error..
with standard selection for home battery i get the same error. another screenshot with also with my grid power net sensor displayed. when i look at this sensor in developer tools it says outout is a number?
Please try disabling following home battery sensors by using default values. Not sure if these sensors are causing you grief. I don't have a battery either. Home battery is just for future enhancement.
sensor_homebattery_power_net:
name: Home battery power net
description: Sensor reporting net battery power in Watts. This works even if no battery is connected, in which case choose any entity with a non-number state.
default: sensor.shift_state
selector:
entity:
domain: sensor
sensor_homebattery_level:
name: Home battery charge level
description: Sensor reporting home battery charge level in percentage. If there is no homebattery_level entity, choose any entity with a non-number state.
default: sensor.shift_state
selector:
entity:
domain: sensor
I don't think it's the battery part that causes it since you would have the same issue then if you have no battery. I'm thinking it's the grid power sensor. Praun and me are using a the state of a meter that returns the value. The Home Assistant documentation states that all states return text, even if it's a number. But since you are using a template and casting the result to int, you are not having the issue. Could you try to cast you grid power value to string and then see what happens? I think you'll run into the same issue as us.
Hi, do you have any solution ? i got the same problem and i got no battery at home. Values are set to default
Please try disabling following home battery sensors by using default values. Not sure if these sensors are causing you grief. I don't have a battery either. Home battery is just for future enhancement.
sensor_homebattery_power_net: name: Home battery power net description: Sensor reporting net battery power in Watts. This works even if no battery is connected, in which case choose any entity with a non-number state. default: sensor.shift_state selector: entity: domain: sensor sensor_homebattery_level: name: Home battery charge level description: Sensor reporting home battery charge level in percentage. If there is no homebattery_level entity, choose any entity with a non-number state. default: sensor.shift_state selector: entity: domain: sensor
I tried this and it doesn't help. I'm not sure where it is going wrong since it works for you but no for me and some other. I'm guessing the only difference that there is, is that we have a grid sensor device that outputs as string and you have a calculation which outputs as integer. But I also see in the calculations that you are casting to float(0), so that should be good.
The thing I changed for myself I remove the home battery stuff and then use "states(grid_power_net) | int" instead of all_power_net
could you please post your code ?
i tried to set it to battery default values before, the sensor for the export value is already a integer, but i don`t know if a comparison between 2 strings is even possible in HA
could you please post your code ?
i tried to set it to battery default values before, the sensor for the export value is already a integer, but i don`t know if a comparison between 2 strings is even possible in HA
Here is the modified code I'm using: https://pastebin.com/LDxdrMdc Just keep in mind it's not the latest version of the code and it doesn't auto start after waiting for solar overnight, but other than that it works.
Hi,
Any updates on this ? I still got the same error with the new script
Hi @knollebolle, @broodro0ster, @praun,
I'm not able to reproduce the error you are seeing. The system had been working for me without issue for few months now. If you can provide more information like logs and traces to give more clue to the issue to narrow down which variable, otherwise it is hard for me to guess what might be the problem.
How do you define "Grid Power Net" value? Can you see the chart of that value?
@praun, I see that you can see "Grid Power Net", so your problem is some other variable, but which one?
Same issue here:
Error: TypeError: '>' not supported between instances of 'int' and 'str'
Hi @kimme1024
What do you see in the log? You should see something similar to this. The first part of the log showed the script talking to the Tesla and adjusting the current accordingly.
14 September 2023 Tesla23m3 solar charger automation sunrise with offset 06:27:26 - 12 hours ago Tesla23m3 Wake up changed to 14 September 2023 at 06:27 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:27:26 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:28 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:06 - 12 hours ago Tesla23m3 Charging amps changed to 6 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:19 - 12 hours ago Tesla23m3 Charger turned on triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:25 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:28 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:36 - 12 hours ago Tesla23m3 Charging amps changed to 5 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:43 - 12 hours ago Tesla23m3 Charging amps changed to 4 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:45 - 12 hours ago Tesla23m3 Charging amps changed to 3 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:46 - 12 hours ago Tesla23m3 Charging amps changed to 2 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:48 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:29 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:48 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:30 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:30:54 - 12 hours ago
And here is a working trace,
I use a HomeWizard P1 meter to read the data live from my digital grid meter. The HA integration polls the device every 5 seconds to get the actual grid consumption. It returns a positive value if you are buying from the grid and a negative value if you are exporting to the grid. Basically the same as you would get from a Shelly meter or a smart meter of you PV installation. As far as I understand from the documentation, HA outputs states as text and not as int. So I think that's the difference between your setup (template casted to int) and the other having issues (using a grid meter/shelly that outputs a state of the net grid usage).
I went to through the script and I looks like everything is casted fine to float so I'm not sure where it goes wrong, but I'm not a specialist either. I just hacked the script a little bit and it works for me, but it's not the nicest solution.
Could you try to cast the result of your grid net template to text instead of int? I guess that will trigger the same issue as we are experiencing.
Hi @kimme1024
What do you see in the log? You should see something similar to this. The first part of the log showed the script talking to the Tesla and adjusting the current accordingly.
14 September 2023 Tesla23m3 solar charger automation sunrise with offset 06:27:26 - 12 hours ago Tesla23m3 Wake up changed to 14 September 2023 at 06:27 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:27:26 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:28 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:06 - 12 hours ago Tesla23m3 Charging amps changed to 6 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:19 - 12 hours ago Tesla23m3 Charger turned on triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:25 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:28 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:28:36 - 12 hours ago Tesla23m3 Charging amps changed to 5 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:43 - 12 hours ago Tesla23m3 Charging amps changed to 4 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:45 - 12 hours ago Tesla23m3 Charging amps changed to 3 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:46 - 12 hours ago Tesla23m3 Charging amps changed to 2 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:48 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:29 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:29:48 - 12 hours ago Tesla23m3 Force data update changed to 14 September 2023 at 06:30 triggered by automation Tesla23m3 solar charger automation sunrise with offset 06:30:54 - 12 hours ago
And here is a working trace,
Related logbook entries:
Tesla Solar Charger getriggerd door status van Wattson Charger
10:18:35 - 4 minuten geleden
Wattson Wake up gewijzigd in 14 september 2023 om 10:18 getriggerd door automatisering Tesla Solar Charger getriggerd door status van Wattson Charger
10:18:35 - 4 minuten geleden
Wattson Force data update gewijzigd in 14 september 2023 om 10:19 getriggerd door automatisering Tesla Solar Charger getriggerd door status van Wattson Charger
10:19:15 - 4 minuten geleden
Screenshot flow:
I use a HomeWizard P1 meter to read the data live from my digital grid meter. The HA integration polls the device every 5 seconds to get the actual grid consumption. It returns a positive value if you are buying from the grid and a negative value if you are exporting to the grid. Basically the same as you would get from a Shelly meter or a smart meter of you PV installation. As far as I understand from the documentation, HA outputs states as text and not as int. So I think that's the difference between your setup (template casted to int) and the other having issues (using a grid meter/shelly that outputs a state of the net grid usage).
I went to through the script and I looks like everything is casted fine to float so I'm not sure where it goes wrong, but I'm not a specialist either. I just hacked the script a little bit and it works for me, but it's not the nicest solution.
Could you try to cast the result of your grid net template to text instead of int? I guess that will trigger the same issue as we are experiencing.
I'm using a setup similar to you. It makes sense that we're encountering the same issues. You said you adapted the script to make it work but I don't understand why you lost functionality like sunrise/sunset during this process? I'd like to take over your script but as my car is parked during multiple days most of the time I'd like to have the sunrise/sunset trigger.
@kimme1024 , can you click on the other tabs to see if we can get more info?
Hi @broodro0ster, changing a sensor value to str will produce a similar error, but I am not sure how it is going to help with this particular problem.
Silly question, just want to confirm that you have created the 2 boolean helpers?
Create 2 helper booleans, eg. Settings > Devices & Services > Helpers > Create Helper > Toggle
Telsa Model3 charge from grid Tesla Model3 stop charging Config the Blueprint automation specifying charger voltage, maximum current and helper booleans created above, ie. Settings > Automations & Scenes > Blueprints > Tesla solar charger automation
@kimme1024 , can you click on the other tabs to see if we can get more info?
Step Config for last (failing) step where the error occurs:
variables:
all_power_net: |-
{% if states(homebattery_power_net) | float(0) > 0 %}
{{ states(grid_power_net) | float(0) + states(homebattery_power_net) | float(0) + (1 + skew_default) * one_amp_watt_step }}
{% else %}
{{ states(grid_power_net) | float(0) }}
{% endif %}
all_current_net: '{{ (all_power_net / one_amp_watt_step) | float }}'
charge_current: |-
{% if states(car_charging_amps) | int < 0 %}
{{ 0 }}
{% elif states(car_charging_amps) | int > car_charger_max_current %}
{{ car_charger_max_current }}
{% else %}
{{ states(car_charging_amps) | int }}
{% endif %}
new_charge_current: |-
{% if all_current_net > 0 %}
{{ [0, charge_current - all_current_net] | max | round(0) }}
{% else %}
{{ [car_charger_max_current, charge_current - all_current_net] | min | round(0) }}
{% endif %}
Changed variables for this step:
grid_power_net: sensor.grid_power_net
homebattery_power_net: sensor.backup_state
homebattery_level: sensor.backup_state
skew: -0.3
Automation config:
variables:
initial_charge_current: 6
wait_car_wakeup: 40
wait_charger_on: 11
wait_charger_off: 5
wait_current_change: 0.3
wait_command_execute: 5
skew_default: -0.3
charge_from_grid: input_boolean.tesla_model_s_charge_from_grid
stop_charger: input_boolean.tesla_model_s_stop_charging
car_charger_voltage: 230
car_charger_max_current: '12'
one_amp_watt_step: '{{ car_charger_voltage * 1 }}'
car_chargelimit_ent: number.wattson_charge_limit
car_chargelimit_last: '{{ expand(car_chargelimit_ent)[0].last_changed | as_timestamp }}'
car_chargelimit_val: '{{ expand(car_chargelimit_ent)[0].state }}'
car_batterylevel_ent: sensor.wattson_battery
car_batterylevel_last: '{{ expand(car_batterylevel_ent)[0].last_changed | as_timestamp }}'
car_batterylevel_val: '{{ expand(car_batterylevel_ent)[0].state }}'
car_charging_amps: number.wattson_charging_amps
trigger:
- platform: state
entity_id:
- binary_sensor.wattson_charger
to: 'on'
- platform: sun
event: sunrise
offset: '+00:30:00'
condition:
- condition: state
entity_id: device_tracker.wattson_location_tracker
state: home
- condition: state
entity_id: binary_sensor.wattson_charger
state: 'on'
action:
- service: button.press
data: {}
target:
entity_id: button.wattson_wake_up
- delay: '{{ wait_car_wakeup }}'
- service: button.press
data: {}
target:
entity_id: button.wattson_force_data_update
- delay: '{{ wait_command_execute }}'
- service: scene.create
data:
scene_id: tesla_solar_charger_script_scene
snapshot_entities:
- number.wattson_charge_limit
- number.wattson_charging_amps
- delay: '{{ wait_command_execute }}'
- repeat:
while:
- condition: and
conditions:
- condition: template
value_template: '{{ is_state(stop_charger, ''off'') }}'
- condition: state
entity_id: binary_sensor.wattson_charger
state: 'on'
- condition: template
value_template: >-
{{ (expand(car_batterylevel_ent)[0].state | int) <
(expand(car_chargelimit_ent)[0].state | int) }}
- condition: or
conditions:
- condition: template
value_template: '{{ is_state(charge_from_grid, ''on'') }}'
- condition: sun
after: sunrise
before: sunset
before_offset: '-00:30:00'
sequence:
- variables:
grid_power_net: sensor.grid_power_net
homebattery_power_net: sensor.backup_state
homebattery_level: sensor.backup_state
skew: |-
{% if skew_default <= -1 %}
{{ skew_default }}
{% elif states(homebattery_level) | float(90) < 90 %}
{{ -1.01 }}
{% else %}
{{ skew_default }}
{% endif %}
- variables:
all_power_net: |-
{% if states(homebattery_power_net) | float(0) > 0 %}
{{ states(grid_power_net) | float(0) + states(homebattery_power_net) | float(0) + (1 + skew_default) * one_amp_watt_step }}
{% else %}
{{ states(grid_power_net) | float(0) }}
{% endif %}
all_current_net: '{{ (all_power_net / one_amp_watt_step) | float }}'
charge_current: >-
{% if states(car_charging_amps) | int < 0 %}
{{ 0 }}
{% elif states(car_charging_amps) | int > car_charger_max_current
%}
{{ car_charger_max_current }}
{% else %}
{{ states(car_charging_amps) | int }}
{% endif %}
new_charge_current: |-
{% if all_current_net > 0 %}
{{ [0, charge_current - all_current_net] | max | round(0) }}
{% else %}
{{ [car_charger_max_current, charge_current - all_current_net] | min | round(0) }}
{% endif %}
- choose:
- conditions:
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.wattson_charging
state: 'off'
sequence:
- if:
- condition: template
value_template: '{{ is_state(charge_from_grid, ''off'') }}'
then:
- service: number.set_value
data:
value: '{{ initial_charge_current }}'
target:
entity_id: number.wattson_charging_amps
else:
- service: number.set_value
data:
value: '{{ charge_current }}'
target:
entity_id: number.wattson_charging_amps
- delay: '{{ wait_command_execute }}'
- service: switch.turn_on
data: {}
target:
entity_id: switch.wattson_charger
- delay: '{{ wait_charger_on }}'
- conditions:
- condition: template
value_template: '{{ is_state(charge_from_grid, ''on'') }}'
sequence:
- delay: '00:00:00'
- conditions:
- condition: state
entity_id: binary_sensor.wattson_charging
state: 'off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.tesla_solar_charger_script_scene
- delay: '{{ wait_command_execute }}'
- service: button.press
data: {}
target:
entity_id: button.wattson_force_data_update
- delay: '{{ wait_command_execute }}'
- stop: >-
Exiting script due to charger turned off manually or
automatically by car when charge limit reached.
- conditions:
- condition: template
value_template: '{{ all_power_net < (0 + skew) * one_amp_watt_step }}'
sequence:
- repeat:
while: >-
{{ (charge_current + repeat.index) <= new_charge_current
}}
sequence:
- service: number.set_value
data_template:
value: '{{ charge_current + repeat.index }}'
target:
entity_id: number.wattson_charging_amps
- delay: '{{ wait_current_change }}'
- conditions:
- condition: template
value_template: '{{ all_power_net >= (1 + skew) * one_amp_watt_step }}'
sequence:
- repeat:
while: >-
{{ (charge_current - repeat.index) >= new_charge_current
}}
sequence:
- service: number.set_value
data_template:
value: '{{ charge_current - repeat.index }}'
target:
entity_id: number.wattson_charging_amps
- delay: '{{ wait_current_change }}'
- conditions:
- condition: template
value_template: >-
{{ (1 + skew) * one_amp_watt_step > all_power_net >= (0 +
skew) * one_amp_watt_step }}
sequence:
- delay: '00:00:00'
- service: button.press
data: {}
target:
entity_id: button.wattson_force_data_update
- delay: '{{ wait_command_execute }}'
- delay:
hours: 0
minutes: 0
seconds: '30'
milliseconds: 0
- if:
- condition: state
entity_id: binary_sensor.wattson_charging
state: 'on'
then:
- variables:
charge_current: '{{ states(car_charging_amps) | int }}'
- repeat:
while: '{{ (charge_current - repeat.index) >= 0 }}'
sequence:
- service: number.set_value
data_template:
value: '{{ charge_current - repeat.index }}'
target:
entity_id: number.wattson_charging_amps
- delay: '{{ wait_current_change }}'
- delay: '{{ wait_command_execute }}'
- service: switch.turn_off
data: {}
target:
entity_id: switch.wattson_charger
- delay: '{{ wait_charger_off }}'
- service: scene.turn_on
target:
entity_id: scene.tesla_solar_charger_script_scene
- delay: '{{ wait_command_execute }}'
- service: button.press
data: {}
target:
entity_id: button.wattson_force_data_update
- delay: '{{ wait_command_execute }}'
mode: single
id: '1694591420381'
alias: Tesla Solar Charger
description: ''
Blueprint config:
id: '1694591420381'
alias: Tesla Solar Charger
description: ''
use_blueprint:
path: flashg/Tesla_solar_charger_automation.yaml
input:
car_location_tracker: device_tracker.wattson_location_tracker
car_button_wake_up: button.wattson_wake_up
car_binary_sensor_charger_pluggedin: binary_sensor.wattson_charger
car_switch_charger: switch.wattson_charger
car_binary_sensor_charging: binary_sensor.wattson_charging
car_number_charging_amps: number.wattson_charging_amps
car_number_charge_limit: number.wattson_charge_limit
car_sensor_battery: sensor.wattson_battery
car_button_forceupdate_ha: button.wattson_force_data_update
toggle_charge_from_grid: input_boolean.tesla_model_s_charge_from_grid
toggle_stop_charger: input_boolean.tesla_model_s_stop_charging
wait_grid_power_net_update: '30'
sensor_homebattery_power_net: sensor.backup_state
charger_max_current: '12'
sensor_homebattery_level: sensor.backup_state
Let me know if you'd need more info
Hi @broodro0ster, changing a sensor value to str will produce a similar error, but I am not sure how it is going to help with this particular problem.
Silly question, just want to confirm that you have created the 2 boolean helpers?
Create 2 helper booleans, eg. Settings > Devices & Services > Helpers > Create Helper > Toggle
Telsa Model3 charge from grid Tesla Model3 stop charging Config the Blueprint automation specifying charger voltage, maximum current and helper booleans created above, ie. Settings > Automations & Scenes > Blueprints > Tesla solar charger automation
For my part, I can conform I did this (except from the typo in your first helper)
Hi @broodro0ster, changing a sensor value to str will produce a similar error, but I am not sure how it is going to help with this particular problem.
Silly question, just want to confirm that you have created the 2 boolean helpers?
Create 2 helper booleans, eg. Settings > Devices & Services > Helpers > Create Helper > Toggle
Telsa Model3 charge from grid Tesla Model3 stop charging Config the Blueprint automation specifying charger voltage, maximum current and helper booleans created above, ie. Settings > Automations & Scenes > Blueprints > Tesla solar charger automation
Well, because you template for the grid sensor is outputting int and when you use a state from a device like a shelly it outputs as string according to the documentation. You don't seem to have a grid sensor in place and calculate your own value which gives you the freedom of choosing the output type. This is the only thing that I think is different between you and the others in here.
The dummy booleans are created in my setup.
Hi @broodro0ster, changing a sensor value to str will produce a similar error, but I am not sure how it is going to help with this particular problem. Silly question, just want to confirm that you have created the 2 boolean helpers? Create 2 helper booleans, eg. Settings > Devices & Services > Helpers > Create Helper > Toggle Telsa Model3 charge from grid Tesla Model3 stop charging Config the Blueprint automation specifying charger voltage, maximum current and helper booleans created above, ie. Settings > Automations & Scenes > Blueprints > Tesla solar charger automation
Well, because you template for the grid sensor is outputting int and when you use a state from a device like a shelly it outputs as string according to the documentation. You don't seem to have a grid sensor in place and calculate your own value which gives you the freedom of choosing the output type. This is the only thing that I think is different between you and the others in here.
The dummy booleans are created in my setup.
As I don't know anything about coding I'm probably going to ask a stupid question here but here I go:
For as far as I understand the formatting of the value of the grid sensor is wrong when using a P1 meter. As we are making the grid sensor ourselves, wouldn't we be able to convert our sensor to the correct value? In de code of the initial sensor, or maybe via another sensor that uses the first one's data?
Hi @kimme1024 ,
Please try selecting something else for these 2 parameters,
sensor_homebattery_power_net: sensor.backup_state
sensor_homebattery_level: sensor.backup_state
Please select something like "sensor.wattson_shift_state".
Home battery is not supported, and just there for future enhancement.
Hi @kimme1024 ,
Please try selecting something else for these 2 parameters,
sensor_homebattery_power_net: sensor.backup_state sensor_homebattery_level: sensor.backup_state
Please select something like "sensor.wattson_shift_state".
Home battery is not supported, and just there for future enhancement.
I'll change it and report back. However sensor.backup_state
is a non-numeric value as requested in the documentation.
EDIT Same error as excpected
@kimme1024 , You got stuck at the last section, ie.
Please click on the last section (the last square bracket circled in red), and then click "step details" and scroll down to the bottom. Please send screen shot of what you see.
I've sent this already in my previous post but here it is again ;)
variables:
all_power_net: |-
{% if states(homebattery_power_net) | float(0) > 0 %}
{{ states(grid_power_net) | float(0) + states(homebattery_power_net) | float(0) + (1 + skew_default) * one_amp_watt_step }}
{% else %}
{{ states(grid_power_net) | float(0) }}
{% endif %}
all_current_net: '{{ (all_power_net / one_amp_watt_step) | float }}'
charge_current: |-
{% if states(car_charging_amps) | int < 0 %}
{{ 0 }}
{% elif states(car_charging_amps) | int > car_charger_max_current %}
{{ car_charger_max_current }}
{% else %}
{{ states(car_charging_amps) | int }}
{% endif %}
new_charge_current: |-
{% if all_current_net > 0 %}
{{ [0, charge_current - all_current_net] | max | round(0) }}
{% else %}
{{ [car_charger_max_current, charge_current - all_current_net] | min | round(0) }}
{% endif %}
Please check the other tabs as well, ie.
Please check the other tabs as well, ie.
was also mentioned in my other post:
grid_power_net: sensor.grid_power_net
homebattery_power_net: sensor.wattson_shift_state
homebattery_level: sensor.wattson_shift_state
skew: -0.3
nothing in the logbook tab
Please also provide screenshot for the next section circled in red which contain the actual values, ie.
Please also provide screenshot for the next section circled in red which contain the actual values, ie.
that's not clickable (greyed out) as it never got activated in the first place.
Hi @broodro0ster, changing a sensor value to str will produce a similar error, but I am not sure how it is going to help with this particular problem. Silly question, just want to confirm that you have created the 2 boolean helpers? Create 2 helper booleans, eg. Settings > Devices & Services > Helpers > Create Helper > Toggle Telsa Model3 charge from grid Tesla Model3 stop charging Config the Blueprint automation specifying charger voltage, maximum current and helper booleans created above, ie. Settings > Automations & Scenes > Blueprints > Tesla solar charger automation
Well, because you template for the grid sensor is outputting int and when you use a state from a device like a shelly it outputs as string according to the documentation. You don't seem to have a grid sensor in place and calculate your own value which gives you the freedom of choosing the output type. This is the only thing that I think is different between you and the others in here. The dummy booleans are created in my setup.
As I don't know anything about coding I'm probably going to ask a stupid question here but here I go:
For as far as I understand the formatting of the value of the grid sensor is wrong when using a P1 meter. As we are making the grid sensor ourselves, wouldn't we be able to convert our sensor to the correct value? In de code of the initial sensor, or maybe via another sensor that uses the first one's data?
@broodro0ster:
Following up on my sidequest: https://community.home-assistant.io/t/sensor-string-trim-and-conversion-to-number/397826 and https://community.home-assistant.io/t/template-string-to-integer/29092
Might this line be of any use for us making our grid sensor?
value_template: "{{ value.split(' ')[1].replace(',','') }}"
or
{{ states.sensor.grid_power_net.state.split()[3] | replace(",", "") | int }}
Hi @broodro0ster, changing a sensor value to str will produce a similar error, but I am not sure how it is going to help with this particular problem. Silly question, just want to confirm that you have created the 2 boolean helpers? Create 2 helper booleans, eg. Settings > Devices & Services > Helpers > Create Helper > Toggle Telsa Model3 charge from grid Tesla Model3 stop charging Config the Blueprint automation specifying charger voltage, maximum current and helper booleans created above, ie. Settings > Automations & Scenes > Blueprints > Tesla solar charger automation
Well, because you template for the grid sensor is outputting int and when you use a state from a device like a shelly it outputs as string according to the documentation. You don't seem to have a grid sensor in place and calculate your own value which gives you the freedom of choosing the output type. This is the only thing that I think is different between you and the others in here. The dummy booleans are created in my setup.
As I don't know anything about coding I'm probably going to ask a stupid question here but here I go: For as far as I understand the formatting of the value of the grid sensor is wrong when using a P1 meter. As we are making the grid sensor ourselves, wouldn't we be able to convert our sensor to the correct value? In de code of the initial sensor, or maybe via another sensor that uses the first one's data?
@broodro0ster:
Following up on my sidequest: https://community.home-assistant.io/t/sensor-string-trim-and-conversion-to-number/397826 and https://community.home-assistant.io/t/template-string-to-integer/29092
Might this line be of any use for us making our grid sensor?
value_template: "{{ value.split(' ')[1].replace(',','') }}"
or{{ states.sensor.grid_power_net.state.split()[3] | replace(",", "") | int }}
tried this:
{{ ((states('sensor.dsmr_reading_electricity_currently_delivered')|float - states('sensor.dsmr_reading_electricity_currently_returned')|float) * 1000)|int }}
sadly it didn't work
I gave it another try. I setup a simple template for my grid sensor to have it available as int, but still the same error. This was the template I tried and it looked fine in the UI: {{ states.sensor.p1_meter_3c39e72f2b38_active_power.state | int(0) }}
This is where I'm crashing. Unfortunately, playtime is over for me today.
Hi @kimme1024, I have made some change, but I don't have my car here at the moment to test this out. Do you mind giving this a try? Basically, I am trying to enforce the integer type for constants.
Hi @kimme1024, I have made some change, but I don't have my car here at the moment to test this out. Do you mind giving this a try? Basically, I am trying to enforce the integer type for constants.
It works! I got past the error point immediately and I just saw it limiting the amps to the car when my washing machine started consuming energy. Next I'll have to check if it goes up again when the washing machine has finished but it's looking very good so far! Thanks a lot!
Excellent! It was my issue after all! I had to enforce the constants as integers!
I didn't encounter the issue because I was using the integer defaults. But if you changed the constant values, they became text values if type is not defined!
I'll update the code.
Thanks @kimme1024 @broodro0ster @praun @knollebolle for your patience.
Excellent! It was my issue after all! I had to enforce the constants as integers!
I didn't encounter the issue because I was using the integer defaults. But if you changed the constant values, they became text values if type is not defined!
I'll update the code.
Thanks @kimme1024 @broodro0ster @praun @knollebolle for your patience.
Great work and thanks for the support!
Thanks a lot! Tried the updated version and it works perfectly!
Glad that it is working for you. Closing issue.
Hi,
I was looking for an automation like this and I saw you created this last week. Awesome and thanks a lot! I don't have a battery, so I used the backup sensor which is not a number, but I get the following error and the script stops: Error: TypeError: '>' not supported between instances of 'int' and 'str'
What's the best way to get around the battery if you don't have one?
EDIT: I'm not sure if it has to do with the battery. I used a sensor with value 0 and I have the same error. Here is a screenshot of the trace where it goes wrong and stops the script. I have a similar error 2 steps earlier, but it doesn't crash the automation. I hope you can help me out so I can start charging using the sun :D https://i.imgur.com/t9xmbQT.png