Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions custom_components/ocpp/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
CONF_CSID,
CONF_HOST,
CONF_IDLE_INTERVAL,
CONF_MAX_CURRENT,
CONF_METER_INTERVAL,
CONF_MONITORED_VARIABLES,
CONF_PORT,
Expand All @@ -19,6 +20,7 @@
DEFAULT_CSID,
DEFAULT_HOST,
DEFAULT_IDLE_INTERVAL,
DEFAULT_MAX_CURRENT,
DEFAULT_MEASURAND,
DEFAULT_METER_INTERVAL,
DEFAULT_PORT,
Expand All @@ -37,6 +39,7 @@
vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
vol.Required(CONF_CSID, default=DEFAULT_CSID): str,
vol.Required(CONF_CPID, default=DEFAULT_CPID): str,
vol.Required(CONF_MAX_CURRENT, default=DEFAULT_MAX_CURRENT): int,
vol.Required(CONF_METER_INTERVAL, default=DEFAULT_METER_INTERVAL): int,
vol.Required(CONF_IDLE_INTERVAL, default=DEFAULT_IDLE_INTERVAL): int,
vol.Required(
Expand Down
2 changes: 2 additions & 0 deletions custom_components/ocpp/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
CONF_HOST = ha.CONF_HOST
CONF_ICON = ha.CONF_ICON
CONF_IDLE_INTERVAL = "idle_interval"
CONF_MAX_CURRENT = "max_current"
CONF_METER_INTERVAL = "meter_interval"
CONF_MODE = ha.CONF_MODE
CONF_MONITORED_VARIABLES = ha.CONF_MONITORED_VARIABLES
Expand All @@ -29,6 +30,7 @@
DEFAULT_CSID = "central"
DEFAULT_CPID = "charger"
DEFAULT_HOST = "0.0.0.0"
DEFAULT_MAX_CURRENT = 32
DEFAULT_PORT = 9000
DEFAULT_SKIP_SCHEMA_VALIDATION = False
DEFAULT_SUBPROTOCOL = "ocpp1.6"
Expand Down
18 changes: 15 additions & 3 deletions custom_components/ocpp/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
import voluptuous as vol

from .api import CentralSystem
from .const import CONF_CPID, DATA_UPDATED, DEFAULT_CPID, DOMAIN, ICON
from .const import (
CONF_CPID,
CONF_MAX_CURRENT,
DATA_UPDATED,
DEFAULT_CPID,
DEFAULT_MAX_CURRENT,
DOMAIN,
ICON,
)
from .enums import Profiles


Expand All @@ -36,22 +44,26 @@ class OcppNumberDescription(NumberEntityDescription):
key="maximum_current",
name="Maximum_Current",
icon=ICON,
initial_value=32,
initial_value=DEFAULT_MAX_CURRENT,
min_value=0,
max_value=32,
max_value=DEFAULT_MAX_CURRENT,
step=1,
),
]


async def async_setup_entry(hass, entry, async_add_devices):
"""Configure the number platform."""

central_system = hass.data[DOMAIN][entry.entry_id]
cp_id = entry.data.get(CONF_CPID, DEFAULT_CPID)

entities = []

for ent in NUMBERS:
if ent.key == "maximum_current":
ent.initial_value = entry.data.get(CONF_MAX_CURRENT, DEFAULT_MAX_CURRENT)
ent.max_value = entry.data.get(CONF_MAX_CURRENT, DEFAULT_MAX_CURRENT)
entities.append(OcppNumber(hass, central_system, cp_id, ent))

async_add_devices(entities, False)
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ocpp/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"port": "Portnummer des Zentralsystems",
"csid": "Identität des Zentralsystems",
"cpid": "Identität des Ladestation",
"max_current": "Maximaler Ladestrom",
"meter_interval": "Abtastintervall Laden (Sekunden)",
"idle_interval": "Abtastintervall Leerlauf (Sekunden)",
"websocket_close_timeout": "Timeout beim Schließen des Websockets (Sekunden)",
Expand Down Expand Up @@ -55,4 +56,4 @@
"single_instance_allowed": "Nur eine Instanz ist erlaubt."
}
}
}
}
3 changes: 2 additions & 1 deletion custom_components/ocpp/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"port": "Central system port number",
"csid": "Central system identity",
"cpid": "Charge point identity",
"max_current": "Maximum charging current",
"meter_interval": "Charging sample interval (seconds)",
"idle_interval": "Charger idle sampling interval (seconds)",
"websocket_close_timeout": "Websocket close timeout (seconds)",
Expand Down Expand Up @@ -55,4 +56,4 @@
"single_instance_allowed": "Only a single instance is allowed."
}
}
}
}
3 changes: 2 additions & 1 deletion custom_components/ocpp/translations/i-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"port": "Central system port number",
"csid": "Central system identity",
"cpid": "Charge point identity",
"max_current": "Maximum charging current",
"meter_interval": "Charging sample interval (seconds)",
"idle_interval": "Charger idle sampling interval (seconds)",
"websocket_close_timeout": "Websocket close timeout (seconds)",
Expand Down Expand Up @@ -55,4 +56,4 @@
"single_instance_allowed": "Only a single instance is allowed."
}
}
}
}
3 changes: 2 additions & 1 deletion custom_components/ocpp/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"port": "Poort",
"csid": "Central system identifier",
"cpid": "Charge point identifier",
"max_current": "Maximale laadstroom",
"meter_interval": "Meetinterval (secondes)",
"websocket_close_timeout": "Websocket close timeout (secondes)",
"websocket_ping_tries": "Websocket successive times to try connection before closing",
Expand Down Expand Up @@ -54,4 +55,4 @@
"single_instance_allowed": "Slechts een exemplaar toegestaan."
}
}
}
}
4 changes: 4 additions & 0 deletions tests/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CONF_CSID,
CONF_HOST,
CONF_IDLE_INTERVAL,
CONF_MAX_CURRENT,
CONF_METER_INTERVAL,
CONF_MONITORED_VARIABLES,
CONF_PORT,
Expand All @@ -21,6 +22,7 @@
CONF_CPID: "test_cpid",
CONF_CSID: "test_csid",
CONF_IDLE_INTERVAL: 900,
CONF_MAX_CURRENT: 32,
CONF_METER_INTERVAL: 60,
CONF_SKIP_SCHEMA_VALIDATION: False,
CONF_WEBSOCKET_CLOSE_TIMEOUT: 1,
Expand Down Expand Up @@ -58,6 +60,7 @@
CONF_CPID: "test_cpid",
CONF_CSID: "test_csid",
CONF_IDLE_INTERVAL: 900,
CONF_MAX_CURRENT: 32,
CONF_METER_INTERVAL: 60,
CONF_MONITORED_VARIABLES: "Current.Export,Current.Import,Current.Offered,Energy.Active.Export.Register,Energy.Active.Import.Register,Energy.Reactive.Export.Register,Energy.Reactive.Import.Register,Energy.Active.Export.Interval,Energy.Active.Import.Interval,Energy.Reactive.Export.Interval,Energy.Reactive.Import.Interval,Frequency,Power.Active.Export,Power.Active.Import,Power.Factor,Power.Offered,Power.Reactive.Export,Power.Reactive.Import,RPM,SoC,Temperature,Voltage",
CONF_SKIP_SCHEMA_VALIDATION: False,
Expand All @@ -72,6 +75,7 @@
CONF_PORT: 9001,
CONF_CPID: "test_cpid_2",
CONF_CSID: "test_csid_2",
CONF_MAX_CURRENT: 32,
CONF_IDLE_INTERVAL: 900,
CONF_METER_INTERVAL: 60,
CONF_MONITORED_VARIABLES: "Current.Export,Current.Import,Current.Offered,Energy.Active.Export.Register,Energy.Active.Import.Register,Energy.Reactive.Export.Register,Energy.Reactive.Import.Register,Energy.Active.Export.Interval,Energy.Active.Import.Interval,Energy.Reactive.Export.Interval,Energy.Reactive.Import.Interval,Frequency,Power.Active.Export,Power.Active.Import,Power.Factor,Power.Offered,Power.Reactive.Export,Power.Reactive.Import,RPM,SoC,Temperature,Voltage",
Expand Down