jmcollin78 / solar_optimizer

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

For the attribute power_entity_id, the select domain is not accepted #67

Open lindsand opened 2 weeks ago

lindsand commented 2 weeks ago

First thanks for a great application!

This is related to #2 and similar in nature.

The BMW / Mini integration uses a selection list to set the charging current in steps of 1 A https://www.home-assistant.io/integrations/bmw_connected_drive#selects

If I put this in my configuration:

power_entity_id: "select.x1_xdrive25e_ac_charging_limit"

then I get an error:

Invalid config for 'solar_optimizer' at solar_optimizer.yaml, line 22: Entity select.x1_xdrive25e_ac_charging_limit belongs to domain select, expected ['input_number', 'number'] for dictionary value 'solar_optimizer->devices->0->power_entity_id', got 'select.x1_xdrive25e_ac_charging_limit'

I changed init.py for my installation a bit to test: ...

from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN _from homeassistant.components.select import DOMAIN as SELECTDOMAIN

... vol.Optional("power_entity_id"): selector.EntitySelector( selector.EntitySelectorConfig( domain=[INPUT_NUMBER_DOMAIN, NUMBER_DOMAIN, _SELECTDOMAIN]

After that the selection list is accepted and I can use _service call select.selectoption to set the value directly: ...the power change is done by a service call change_power_service: "select/select_option"

I'm using a input_number helper and automation for the moment to set the value but it's difficult to keep the values in sync as they can be changed by multiple applications. So it would be clearer and more stable to have a direct setup.

... action: select.select_option target: entity_id: select.x1_xdrive25e_ac_charging_limit data: option: "{{ int(states('input_number.x1_xdrive25e_ac_charging_limit')) }}"

jmcollin78 commented 2 weeks ago

Hello, fine ! I will integrate this into the next release.

If you are able to do a PR, then I can merge it immediatly.

lindsand commented 2 weeks ago

Next release is fine. I'm not in a hurry, I live in the north and the sun starts to be lazy already this time of the year. So I'm preparing for next spring...