-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable json payload attribute #67
Comments
as suggested by @matsekberg json-path could be used. Or to keep it simple (json-path seems a bit too much for just selecting a specific property) smth like https://github.com/sindresorhus/dot-prop could be sufficient? |
I would love JSONPath, at the moment I manually have to seperate it into more than one topic which is a bit of a pain |
Do you really need json path or would it be sufficient to just select properties/subproperties via dot-notation? E.g. |
I think dot notation is fine. So the JSON for an Airconditioner could be as simple as this. {
"mode": 1,
"temp": 22,
"set_temp": 20
} So I could just do |
Not sure if I should add this here, but I've got another example where the current JSON implementation isn't working.
Now I have configured a Temperature sensor in homekit2mqtt, but I cannot extract the "Temperature" value. And for the Humidty sensor I've configured I cannot extract the "Humidity" value. |
Yes, that's exactly what a configurable json property would be for. Until it's implemented you can only work around that by e.g. a Node-RED flow that subscribes to Example js code for a Node-RED function node (untested): const data = JSON.parse(msg.payload);
Object.keys(data).forEach(key => {
node.send({
topic: msg.topic + '/' + key,
payload: String(data[key]);
});
}); |
implemented in v1.1.0 |
Hi, i've installed homekit2mqtt 1.1.2 and i try to comunicate with my son off sensor. |
In your case I think you can use the JSON Property in the websever editor just under statusTemperature for the specific accessory and put |
Hi, In the webinterface I have set "Status Temperature" to tele/sonoff_th1/SENSOR, and "JSON Property" to SI7021.Temperature I can´t get the value to show up in Homekit p.s.: homekit2mqtt version is 1.1.2 Best, |
To use 'JSON Property' in TemperatureSensor and HumiditySensor, you have to modify it as follows. service file
sensor payload
mapfile
|
until now - if json parsing isn't disabled - homekit2mqtt tries to use the attribute
val
(following https://github.com/mqtt-smarthome/mqtt-smarthome/blob/master/Architecture.md). This should be configurable to allow non-mqtt-smarthome json payloads.The text was updated successfully, but these errors were encountered: