Skip to content

Commit

Permalink
add option to skip schema vaidation (#362)
Browse files Browse the repository at this point in the history
Co-authored-by: lbbrhzn <@lbbrhzn>
  • Loading branch information
lbbrhzn authored Feb 3, 2022
1 parent 71b1522 commit 2784e30
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
8 changes: 7 additions & 1 deletion custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions custom_components/ocpp/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
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 @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ocpp/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion custom_components/ocpp/translations/i-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion custom_components/ocpp/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions tests/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2784e30

Please sign in to comment.