class FoxESSEnergyBatMinSoC(CoordinatorEntity, NumberEntity):
_attr_device_class = DEVICE_CLASS_BATTERY
_attr_unit_of_measurement = "%"
_attr_value = 4
def __init__(self, coordinator, name, deviceID):
super().__init__(coordinator=coordinator)
_LOGGER.debug("Initing Entity - Bat Min SoC")
self._attr_name = name+" - Bat Min SoC"
self._attr_name = name+" - Bat Min SoC"
self._attr_unique_id = deviceID+"-bat_min_SoC"
def set_value(self, value: float) -> None:
"""Update the current value."""
async def async_set_value(self, value):
"""Update the current value."""
self._attr_value = value
self.async_write_ha_state()
Documentation does not cover that topic Is there any other source of knowledge different thathttps://developers.home-assistant.io/docs/core/entity/number/ ?
Tried both adding only the async version of set_value, plus have the value property, and have defined it within a number.py, but still same behaviour - no editable value.
Have now added those attributes, and they are being pulled through by the front end, however, still no adjustable input. @macxq would you perhaps mind sharing your complete number.py, so I can try and make sure I’m doing the correct things?
@macxq also coincidentally - it appears you’re trying to achieve the same thing as me with Solar inverter control?
Ah - sorted it - the issue was that I was not calling async_setup_platforms() with “sensor” and “number” separately, but instead I was importing ‘number’ into the ‘sensor.py’ setup script.
Wrong code:
PLATFORMS: list[str] = ["sensor"]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Solarman Collector from a config entry."""
_LOGGER.debug(f'__init__.py:async_setup_entry({entry.as_dict()})')
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(update_listener))
return True
Fixed code:
PLATFORMS: list[str] = ["sensor","number"]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Solarman Collector from a config entry."""
_LOGGER.debug(f'__init__.py:async_setup_entry({entry.as_dict()})')
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(update_listener))
return True