diff --git a/custom_components/ocpp/api.py b/custom_components/ocpp/api.py index e59e80b7..29638a58 100644 --- a/custom_components/ocpp/api.py +++ b/custom_components/ocpp/api.py @@ -302,9 +302,15 @@ def __init__( entry: ConfigEntry, central: CentralSystem, interval_meter_metrics: int = 10, + skip_schema_validation: bool = False, ): - """Instantiate instance of a ChargePoint.""" + """Instantiate a ChargePoint.""" + super().__init__(id, connection) + + for action in self.route_map: + self.route_map[action]["_skip_schema_validation"] = skip_schema_validation + self.interval_meter_metrics = interval_meter_metrics self.hass = hass self.entry = entry diff --git a/custom_components/ocpp/config_flow.py b/custom_components/ocpp/config_flow.py index 01850664..7331a5ec 100644 --- a/custom_components/ocpp/config_flow.py +++ b/custom_components/ocpp/config_flow.py @@ -10,6 +10,7 @@ CONF_METER_INTERVAL, CONF_MONITORED_VARIABLES, CONF_PORT, + CONF_SKIP_SCHEMA_VALIDATION, CONF_WEBSOCKET_CLOSE_TIMEOUT, CONF_WEBSOCKET_PING_INTERVAL, CONF_WEBSOCKET_PING_TIMEOUT, @@ -21,6 +22,7 @@ DEFAULT_MEASURAND, DEFAULT_METER_INTERVAL, DEFAULT_PORT, + DEFAULT_SKIP_SCHEMA_VALIDATION, DEFAULT_WEBSOCKET_CLOSE_TIMEOUT, DEFAULT_WEBSOCKET_PING_INTERVAL, DEFAULT_WEBSOCKET_PING_TIMEOUT, @@ -49,6 +51,9 @@ vol.Required( CONF_WEBSOCKET_PING_TIMEOUT, default=DEFAULT_WEBSOCKET_PING_TIMEOUT ): int, + vol.Required( + CONF_SKIP_SCHEMA_VALIDATION, default=DEFAULT_SKIP_SCHEMA_VALIDATION + ): bool, } ) STEP_USER_MEASURANDS_SCHEMA = vol.Schema( diff --git a/custom_components/ocpp/const.py b/custom_components/ocpp/const.py index b4de2833..a9072fb7 100644 --- a/custom_components/ocpp/const.py +++ b/custom_components/ocpp/const.py @@ -16,6 +16,7 @@ CONF_NAME = ha.CONF_NAME CONF_PASSWORD = ha.CONF_PASSWORD CONF_PORT = ha.CONF_PORT +CONF_SKIP_SCHEMA_VALIDATION = "skip_schema_validation" CONF_STEP = input_number.CONF_STEP CONF_SUBPROTOCOL = "subprotocol" CONF_UNIT_OF_MEASUREMENT = ha.CONF_UNIT_OF_MEASUREMENT @@ -29,6 +30,7 @@ DEFAULT_CPID = "charger" DEFAULT_HOST = "0.0.0.0" DEFAULT_PORT = 9000 +DEFAULT_SKIP_SCHEMA_VALIDATION = False DEFAULT_SUBPROTOCOL = "ocpp1.6" DEFAULT_METER_INTERVAL = 60 DEFAULT_IDLE_INTERVAL = 900 diff --git a/custom_components/ocpp/translations/en.json b/custom_components/ocpp/translations/en.json index 3ee6669b..e33f4662 100644 --- a/custom_components/ocpp/translations/en.json +++ b/custom_components/ocpp/translations/en.json @@ -14,7 +14,8 @@ "websocket_close_timeout": "Websocket close timeout (seconds)", "WEBSOCKET_PING_TRIES": "Websocket successive times to try connection before closing", "websocket_ping_interval": "Websocket ping interval (seconds)", - "websocket_ping_timeout": "Websocket ping timeout (seconds)" + "websocket_ping_timeout": "Websocket ping timeout (seconds)", + "skip_schema_validation": "Skip OCPP schema validation" } }, "measurands": { diff --git a/custom_components/ocpp/translations/i-default.json b/custom_components/ocpp/translations/i-default.json index 768d5bd0..e33f4662 100644 --- a/custom_components/ocpp/translations/i-default.json +++ b/custom_components/ocpp/translations/i-default.json @@ -12,8 +12,10 @@ "meter_interval": "Charging sample interval (seconds)", "idle_interval": "Charger idle sampling interval (seconds)", "websocket_close_timeout": "Websocket close timeout (seconds)", + "WEBSOCKET_PING_TRIES": "Websocket successive times to try connection before closing", "websocket_ping_interval": "Websocket ping interval (seconds)", - "websocket_ping_timeout": "Websocket ping timeout (seconds)" + "websocket_ping_timeout": "Websocket ping timeout (seconds)", + "skip_schema_validation": "Skip OCPP schema validation" } }, "measurands": { diff --git a/custom_components/ocpp/translations/nl.json b/custom_components/ocpp/translations/nl.json index 481743ea..9b4498b1 100644 --- a/custom_components/ocpp/translations/nl.json +++ b/custom_components/ocpp/translations/nl.json @@ -11,8 +11,10 @@ "cpid": "Charge point identifier", "meter_interval": "Meetinterval (secondes)", "websocket_close_timeout": "Websocket close timeout (secondes)", + "WEBSOCKET_PING_TRIES": "Websocket successive times to try connection before closing", "websocket_ping_interval": "Websocket ping interval (secondes)", - "websocket_ping_timeout": "Websocket ping timeout (secondes)" + "websocket_ping_timeout": "Websocket ping timeout (secondes)", + "skip_schema_validation": "Skip OCPP schema validation" } }, "measurands": { diff --git a/tests/const.py b/tests/const.py index 7647a75b..01658d4d 100644 --- a/tests/const.py +++ b/tests/const.py @@ -7,6 +7,7 @@ CONF_METER_INTERVAL, CONF_MONITORED_VARIABLES, CONF_PORT, + CONF_SKIP_SCHEMA_VALIDATION, CONF_WEBSOCKET_CLOSE_TIMEOUT, CONF_WEBSOCKET_PING_INTERVAL, CONF_WEBSOCKET_PING_TIMEOUT, @@ -21,6 +22,7 @@ CONF_CSID: "test_csid", CONF_IDLE_INTERVAL: 900, CONF_METER_INTERVAL: 60, + CONF_SKIP_SCHEMA_VALIDATION: False, CONF_WEBSOCKET_CLOSE_TIMEOUT: 1, CONF_WEBSOCKET_PING_TRIES: 0, CONF_WEBSOCKET_PING_INTERVAL: 1, @@ -58,6 +60,7 @@ 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", + CONF_SKIP_SCHEMA_VALIDATION: False, CONF_WEBSOCKET_CLOSE_TIMEOUT: 1, CONF_WEBSOCKET_PING_TRIES: 0, CONF_WEBSOCKET_PING_INTERVAL: 1,