You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background : I'm probably over my head with my limited skills, but as a proof of concept I have been looking at using Zwave-js-ui as a third-party connection to OpenHAB (Home Automation) as an alternative ZWave provider using an MQTT broker. OpenHAB uses jinjava to "unwrap" the MQTT messages from Zwave-js-ui. Most work fine, but one type uses the zwave hexadecimal converted to an integer as a filter and springs an error. It must work in Home Assistant, but that is a javascript application.
Details:
Message: {"value_template":"{{ {22: \"Window/door is open\",23: \"Window/door is closed\",5632: \"Window/door is open in regular position\",5633: \"Window/door is open in tilt position\"}[value_json.value] | default(value_json.value) }}","icon":"mdi:alarm-light","state_topic":"zwave/nodeID_10/113/0/Access_Control/Door_state","json_attributes_topic":"zwave/nodeID_10/113/0/Access_Control/Door_state","device":{"identifiers":["zwavejs2mqtt_0xe2bd1ff1_node10"],"manufacturer":"Zooz","model":"Tilt Shock XS Sensor (ZSE43)","name":"nodeID_10","sw_version":"1.20.1"},"name":"nodeID_10_notification_access_control_door_state","unique_id":"zwavejs2mqtt_0xe2bd1ff1_10-113-0-Access_Control-Door_state"}
Error: Executing the JINJA-transformation failed: An error occurred while transformation. InterpretException: Error resolving expression [{22: "Window/door is open",23: "Window/door is closed",5632: "Window/door is open in regular position",5633: "Window/door is open in tilt position"}[value_json.value] | default(value_json.value)]: TemplateStateException: Dict key must be a string or identifier, was: 22
Section of OpenHAB code that calls jinjava:
/**
* Transforms the input <code>value</code> by Jinja template.
*
* @param template Jinja template
* @param value String may contain JSON
* @throws TransformationException
*/
@Override
public @Nullable String transform(String template, String value) throws TransformationException {
String transformationResult;
Map<String, @Nullable Object> bindings = new HashMap<>();
logger.debug("about to transform '{}' by the function '{}'", value, template);
bindings.put("value", value);
try {
JsonNode tree = new ObjectMapper().readTree(value);
bindings.put("value_json", toObject(tree));
} catch (IOException e) {
// ok, then value_json is null...
}
try {
transformationResult = jinjava.render(template, bindings);
} catch (FatalTemplateErrorsException e) {
throw new TransformationException("An error occurred while transformation. " + e.getMessage(), e);
}
logger.debug("transformation resulted in '{}'", transformationResult);
return transformationResult;
}
I did capture value, tree and bindings during the transformation.
value: {"time":1688240438204,"value":22,"nodeName":"","nodeLocation":""}
tree: '{"time":1688240438204,"value":22,"nodeName":"","nodeLocation":""}
bindings: {value_json={nodeName=, time=1688240438204, value=22, nodeLocation=}, value={"time":1688240438204,"value":22,"nodeName":"","nodeLocation":""}}
So the question as above; Can an integer be allowed as a key or identifier?
The text was updated successfully, but these errors were encountered:
Background : I'm probably over my head with my limited skills, but as a proof of concept I have been looking at using Zwave-js-ui as a third-party connection to OpenHAB (Home Automation) as an alternative ZWave provider using an MQTT broker. OpenHAB uses jinjava to "unwrap" the MQTT messages from Zwave-js-ui. Most work fine, but one type uses the zwave hexadecimal converted to an integer as a filter and springs an error. It must work in Home Assistant, but that is a javascript application.
Details:
{"value_template":"{{ {22: \"Window/door is open\",23: \"Window/door is closed\",5632: \"Window/door is open in regular position\",5633: \"Window/door is open in tilt position\"}[value_json.value] | default(value_json.value) }}","icon":"mdi:alarm-light","state_topic":"zwave/nodeID_10/113/0/Access_Control/Door_state","json_attributes_topic":"zwave/nodeID_10/113/0/Access_Control/Door_state","device":{"identifiers":["zwavejs2mqtt_0xe2bd1ff1_node10"],"manufacturer":"Zooz","model":"Tilt Shock XS Sensor (ZSE43)","name":"nodeID_10","sw_version":"1.20.1"},"name":"nodeID_10_notification_access_control_door_state","unique_id":"zwavejs2mqtt_0xe2bd1ff1_10-113-0-Access_Control-Door_state"}
Executing the JINJA-transformation failed: An error occurred while transformation. InterpretException: Error resolving expression [{22: "Window/door is open",23: "Window/door is closed",5632: "Window/door is open in regular position",5633: "Window/door is open in tilt position"}[value_json.value] | default(value_json.value)]: TemplateStateException: Dict key must be a string or identifier, was: 22
value:
{"time":1688240438204,"value":22,"nodeName":"","nodeLocation":""}
tree:
'{"time":1688240438204,"value":22,"nodeName":"","nodeLocation":""}
bindings:
{value_json={nodeName=, time=1688240438204, value=22, nodeLocation=}, value={"time":1688240438204,"value":22,"nodeName":"","nodeLocation":""}}
So the question as above; Can an integer be allowed as a key or identifier?
The text was updated successfully, but these errors were encountered: