Skip to content

Commit

Permalink
make interval changeable
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Feb 26, 2025
1 parent 2457933 commit 1b06dd9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/carconnectivity_connectors/tronity/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from carconnectivity.drive import ElectricDrive, GenericDrive
from carconnectivity.units import Power, Length
from carconnectivity.charging import ChargingConnector, Charging
from carconnectivity.attributes import BooleanAttribute, DurationAttribute
from carconnectivity.attributes import BooleanAttribute, DurationAttribute, GenericAttribute
from carconnectivity.commands import Commands
from carconnectivity.command_impl import ChargingStartStopCommand

Expand Down Expand Up @@ -55,6 +55,16 @@ def __init__(self, connector_id: str, car_connectivity: CarConnectivity, config:

self.connected: BooleanAttribute = BooleanAttribute(name="connected", parent=self, tags={'connector_custom'})
self.interval: DurationAttribute = DurationAttribute(name="interval", parent=self, tags={'connector_custom'})

def __check_interval(attribute: GenericAttribute, value: Any) -> Any:
del attribute
if value is not None and value < timedelta(seconds=180):
raise ValueError('Intervall must be at least 180 seconds')
return value

self.interval._is_changeable = True # pylint: disable=protected-access
self.interval._add_on_set_hook(__check_interval) # pylint: disable=protected-access

self.commands: Commands = Commands(parent=self)

LOG.info("Loading tronity connector with config %s", config_remove_credentials(config))
Expand Down

0 comments on commit 1b06dd9

Please sign in to comment.