jmcollin78 / solar_optimizer

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

Power Production not valued #50

Closed siegelpeter closed 1 week ago

siegelpeter commented 1 month ago

Version of the custom_component

1.7 la

Configuration


algorithm:
  initial_temp: 1000
  min_temp: 0.1
  cooling_factor: 0.95
  max_iteration_number: 100

devices:
  - name: "Reservoir pump"
    # The switch that controls the tank pump
    entity_id: "switch.eg_bad_licht_schalter"
    # the power of this pump
    power_max: 50
    # Always usable
    # check_usable_template: "{{ True }}"
    # 15 min minimum activation
    duration_min: 15
    # 5 min deactivation minimum
    duration_stop_min: 5
    # On enable/disable via a service call
    action_mode: "service_call"
    # The service enabling the switch
    activation_service: "switch/turn_on"
    # The service to deactivate the switch
    deactivation_service: "switch/turn_off"

grafik

Active Power: grafik

net Consumption: grafik Is negative when power is exported (most of the day)

Describe the bug

the device is turned on as soon as there is enough power. This works well. But in the evening there is not enough power the device is not turned off. The Logs say that power production is not valued. but according to homeassistant it has the value 0. What can i do?

Debug log


Logger: custom_components.solar_optimizer.coordinator
Quelle: custom_components/solar_optimizer/coordinator.py:116
Integration: Solar Optimizer (Dokumentation, Probleme)
Erstmals aufgetreten: 11. August 2024 um 22:45:20 (99 Vorkommnisse)
Zuletzt protokolliert: 21:05:20

Power production is not valued. Solar Optimizer will be disabled
jmcollin78 commented 4 weeks ago

Hello, yes this is something I also have seen. I will fix that. The bug is, when the production is 0 or undefined, the calculation stops but forget to turn off all device.

siegelpeter commented 3 weeks ago

Thank you

siegelpeter commented 2 weeks ago

Tried to fix this by deactivating the devices like this:

        power_production = get_safe_float(self.hass, self._power_production_entity_id)
        if not power_production:
            _LOGGER.warning(
                "Power production is not valued. Solar Optimizer will be disabled"
            )
            for _, device in enumerate(self._devices):
                await device.deactivate()
            return None

But i get the following error in the logs: Logger: homeassistant.helpers.service Quelle: helpers/service.py:301

Referenced entities light.bad_eg are missing or not currently available

As im new to python and ha development i do not know why this is happening. Can you point me in the right direction?

would it make sense to simply return 0 if the power is not valued instead of aborting ?

jmcollin78 commented 1 week ago

Tried to fix this by deactivating the devices like this:

        power_production = get_safe_float(self.hass, self._power_production_entity_id)
        if not power_production:
            _LOGGER.warning(
                "Power production is not valued. Solar Optimizer will be disabled"
            )
            for _, device in enumerate(self._devices):
                await device.deactivate()
            return None

But i get the following error in the logs: Logger: homeassistant.helpers.service Quelle: helpers/service.py:301

Referenced entities light.bad_eg are missing or not currently available

As im new to python and ha development i do not know why this is happening. Can you point me in the right direction?

would it make sense to simply return 0 if the power is not valued instead of aborting ?

Thank you I will test that.

jmcollin78 commented 1 week ago

https://github.com/jmcollin78/solar_optimizer/releases/tag/1.7.1