Skip to content

Commit

Permalink
Merge pull request #12 from tschamm/bugfixes_and_deprecations
Browse files Browse the repository at this point in the history
Fixed deprecation warnings and Charging Energy Sensor
  • Loading branch information
mk-maddin authored Sep 24, 2022
2 parents aa32fc4 + 798d44d commit 240c2a5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion custom_components/wattpilot/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def device_info(self) -> DeviceInfo:
default_model=GetChargerProp(self._charger,'typ',getattr(self._charger,'devicetype',STATE_UNKNOWN)),
default_name=getattr(self._charger,'name',getattr(self._charger,'hostname',STATE_UNKNOWN)),
sw_version=getattr(self._charger,'firmware',STATE_UNKNOWN),
configuration_url=getattr(self._charger,'url',STATE_UNKNOWN)
#configuration_url=getattr(self._charger,'url',STATE_UNKNOWN)
)
#_LOGGER.debug("%s - %s: device_info result: %s", self._charger_id, self._identifier, info)
return info
Expand Down
36 changes: 18 additions & 18 deletions custom_components/wattpilot/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,34 @@ class ChargerNumber(ChargerPlatformEntity, NumberEntity):

def _init_platform_specific(self):
"""Platform specific init actions"""
self._min=self._entity_cfg.get('min_value', None)
if not self._min is None:
self._min=float(self._min)
self._max=self._entity_cfg.get('max_value', None)
if not self._max is None:
self._max=float(self._max)
self._step=self._entity_cfg.get('step', None)
if not self._step is None:
self._step=float(self._step)
self._native_min=self._entity_cfg.get('native_min_value', None)
if not self._native_min is None:
self._native_min=float(self._native_min)
self._native_max=self._entity_cfg.get('native_max_value', None)
if not self._native_max is None:
self._native_max=float(self._native_max)
self._native_step=self._entity_cfg.get('native_step', None)
if not self._native_step is None:
self._native_step=float(self._native_step)
self._mode=self._entity_cfg.get('mode', None)


@property
def min_value(self) -> float | None:
def native_min_value(self) -> float | None:
"""Return the minimum accepted value (inclusive) for this entity."""
return self._min
return self._native_min


@property
def max_value(self) -> float | None:
def native_max_value(self) -> float | None:
"""Return the maximum accepted value (inclusive) for this entity."""
return self._max
return self._native_max


@property
def step(self) -> float | None:
def native_step(self) -> float | None:
"""Return the resolution of the values for this entity."""
return self._step
return self._native_step


@property
Expand All @@ -128,12 +128,12 @@ def mode(self) -> str | None:
return self._mode


async def async_set_value(self, value) -> None:
async def asyc_native_set_value(self, value) -> None:
"""Async: Change the current value."""
try:
_LOGGER.debug("%s - %s: async_set_value: value was changed to: %s", self._charger_id, self._identifier, float)
_LOGGER.debug("%s - %s: asyc_native_set_value: value was changed to: %s", self._charger_id, self._identifier, float)
if (self._identifier == 'fte'):
_LOGGER.debug("%s - %s: async_set_value: apply ugly workaround to always set next trip distance to kWH instead of KM", self._charger_id, self._identifier)
_LOGGER.debug("%s - %s: asyc_native_set_value: apply ugly workaround to always set next trip distance to kWH instead of KM", self._charger_id, self._identifier)
await async_SetChargerProp(self._charger,'esk',True)
await async_SetChargerProp(self._charger,self._identifier,value,force_type=self._set_type)
except Exception as e:
Expand Down
38 changes: 19 additions & 19 deletions custom_components/wattpilot/number.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ number:
# name: <optional: name of the switch within HA>
# description: <optional: key within HA>
# icon: <optional: key within HA>
# min_value: <optional: the minimum accepted value>
# max_value: <optional: the maximum accepted value>
# step: <optional: Defines the resolution of the values, i.e. the smallest increment or decrement>
# native_min_value: <optional: the minimum accepted value>
# native_max_value: <optional: the maximum accepted value>
# native_step: <optional: Defines the resolution of the values, i.e. the smallest increment or decrement>
# mode: <optional: Defines how the number should be displayed in the UI. 'auto', 'box' or 'slider'
# enabled: <optional: if set to False entity is by default disabled>
# device_class: <optional: key within HA>
Expand All @@ -25,9 +25,9 @@ number:
name: "Charging Power"
description: "Charging range per Hour"
icon: "mdi:car-electric"
min_value: 6.0
max_value: 16.0
step: 1.0
native_min_value: 6.0
native_max_value: 16.0
native_step: 1.0
mode: slider
device_class: current

Expand All @@ -36,29 +36,29 @@ number:
name: "Max Price"
description: "Lumina Strom/aWattar maximum price in cent"
icon: "mdi:cash-100"
min_value: 0
max_value: 99999
step: 1
native_min_value: 0
native_max_value: 99999
native_step: 1
entity_category: config

- id: fmt
set_type: int
name: "Min Charging Time"
description: "Minimum charging time after the charging has started"
icon: "mdi:car-clock"
min_value: 30000
step: 30000
unit_of_measurement: "ms"
native_min_value: 30000
native_step: 30000
native_unit_of_measurement: "ms"
entity_category: config

- id: fst
set_type: float
name: "Start Chargig at"
description: "PV Surplus start charging power"
icon: "mdi:solar-power"
min_value: 1320
step: 1
unit_of_measurement: "W"
native_min_value: 1320
native_step: 1
native_unit_of_measurement: "W"
device_class: power
entity_category: config

Expand All @@ -67,9 +67,9 @@ number:
name: "Next Trip Charging"
description: "Defined amount of energy will be provided unitl the next scheduled ride"
icon: "mdi:road-variant"
min_value: 100.0
max_value: 50000.0
step: 10.0
native_min_value: 100.0
native_max_value: 50000.0
native_step: 10.0
device_class: energy
unit_of_measurement: "Wh"
native_unit_of_measurement: "Wh"

2 changes: 1 addition & 1 deletion custom_components/wattpilot/sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ sensor:
description: "Charging energy used for current car charging process"
icon: "mdi:lightning-bolt-circle"
device_class: power
unit_of_measurement: "W"
unit_of_measurement: W
value_id: 11
attribute_ids:
- L1_Voltage:0
Expand Down

0 comments on commit 240c2a5

Please sign in to comment.