jmcollin78 / solar_optimizer

The Solar Optimizer integration for Home Assistant starts and stops your equipments depending on the Solar net production
MIT License
53 stars 10 forks source link

Always charge car during the night when below target charge level #5

Open pvmil opened 7 months ago

pvmil commented 7 months ago

The Optimizer can result in not having the car charged in the morning when there was not enough sugar power available to charge the car. I would not like to solve this with my own scripting, it works be nice to manage this in the solar Optimizer

I'd like to see a parameter activate device time to enable a forced start (charging car, starting dishwasher,..). Typically this is during night time in my case

Describe alternatives you've considered Using the manual control option to accomplish this wich I expect will work

Thanks for your great efforts!

jmcollin78 commented 7 months ago

Yes, I have in mind for doing that one day. I keep it.

Please be patient, I have really no time for doing that quickly.

MrBLJ commented 3 months ago

I made an automation for this particular case, in order to keep the battery level of my car at a minimum. I understand that you'd like the addon to handle this part as well, but in any case I think it could help you or someone else.

Pre-requisite :

What the automation does : Based on the charge plan defined using an input_select, the charge limit of the car is adjusted before the scheduled charging begins. The optimizer is turned off if needed and turned back on in the morning. Minimum battery level is set to 50%.

alias: 🌞 Solar Optimizer - Titine
description: ""
trigger:
  - alias: At 06:00 AM
    platform: time
    at: "06:00:00"
    id: morning
  - alias: At 10:00 PM
    platform: time
    at: "22:00:00"
    id: night
condition:
  - condition: state
    entity_id: device_tracker.titine_location_tracker
    state: home
    alias: Titine is at home
action:
  - alias: Depending on the time of day
    choose:
      - conditions:
          - condition: trigger
            id:
              - morning
            alias: When triggered in the morning
        sequence:
          - alias: >-
              Adjust battery level based on Titine's charging plan
            choose:
              - conditions:
                  - condition: state
                    entity_id: input_select.titine_charge_plan
                    state: Solar
                    alias: Charging plan is set to solar
                sequence:
                  - alias: Set battery charge limit to 100%
                    service: number.set_value
                    metadata: {}
                    data:
                      value: "100"
                    target:
                      entity_id: number.titine_charge_limit
                  - service: switch.turn_on
                    target:
                      entity_id: switch.enable_solar_optimizer_titine
                    data: {}
                    alias: Enable solar optimization for Titine
                alias: Charging plan is set to solar and battery level is below 50%
              - conditions:
                  - condition: state
                    entity_id: input_select.titine_charge_plan
                    state: Off-peak hours
                    alias: "Charging plan: Off-peak hours"
                sequence:
                  - alias: Set battery charge limit to 75%
                    service: number.set_value
                    metadata: {}
                    data:
                      value: "75"
                    target:
                      entity_id: number.titine_charge_limit
                  - service: switch.turn_off
                    target:
                      entity_id: switch.enable_solar_optimizer_titine
                    data: {}
                    alias: Disable solar optimization for Titine
                alias: Charging plan is set to off-peak hours
        alias: In the morning
      - conditions:
          - condition: trigger
            id:
              - night
            alias: When triggered in the evening
        sequence:
          - alias: >-
              Adjust battery level based on Titine's charging plan
            choose:
              - conditions:
                  - condition: state
                    entity_id: input_select.titine_charge_plan
                    state: Solar
                    alias: Charging plan is set to solar
                sequence:
                  - alias: Set battery charge limit to 50%
                    service: number.set_value
                    metadata: {}
                    data:
                      value: "50"
                    target:
                      entity_id: number.titine_charge_limit
                  - if:
                      - condition: numeric_state
                        entity_id: sensor.titine_battery
                        below: 50
                        alias: If battery level is below 50%
                    then:
                      - service: switch.turn_off
                        target:
                          entity_id: switch.enable_solar_optimizer_titine
                        data: {}
                        alias: Disable solar optimization for Titine
                    alias: If battery level is below 50%, disable solar optimization.
                alias: Charging plan is set to solar
              - conditions:
                  - condition: state
                    entity_id: input_select.titine_charge_plan
                    state: Off-peak hours
                    alias: "Charging plan: Off-peak hours"
                sequence:
                  - if:
                      - alias: >-
                          Battery charge limit is below 75%
                        condition: numeric_state
                        entity_id: number.titine_charge_limit
                        below: 75
                    then:
                      - alias: Set battery charge limit to 75%
                        service: number.set_value
                        metadata: {}
                        data:
                          value: "75"
                        target:
                          entity_id: number.titine_charge_limit
                    alias: If battery charge limit is below 75%, set it to 75%
                  - service: switch.turn_off
                    target:
                      entity_id: switch.enable_solar_optimizer_titine
                    data: {}
                    alias: Disable solar optimization for Titine
                alias: Charging plan is set to off-peak hours
        alias: In the evening
mode: single

I should turn this into a blueprint but I'm lazy

jmcollin78 commented 3 months ago

I will intégrate this directly in the integration. It is very interesting for many people (and I).