Open Radiotechniman opened 4 years ago
Thanks for the suggestion and also for the hint to "better logic". When I have some time left, I'll have a look at it. But don't wait for it.
Running in the same issue again today, I was planning to make a request for an feature . . I completely forgot I had already made the request :-D
Man, I have so many 'projects' and this (or Homey in general) is not very high on my prio-list. It is safe to say I will not implement this, but I leave it open in case someone else wants to implement this.
While I'd love to be able to implement this it is not something I can do.. I've attempted multiple times but i just don't get it. As a workaround i've used HomeyScript to format the JSON data and store it in a variable which I can then use in a Flow. All-in-all one flow is needed to update one VD
for posterity: enter the below in a HomeyScript
// This is the format of my JSON
// '{"hum": "62","battery": "81","temp": "20.3","name": "slaapkamer"}'
const payload = JSON.parse(args[0]);
//echo the data to the log for troubleshooting
//console.log(payload)
//set the different tags
tag('battery', payload.battery);
tag('hum', payload.hum);
tag('temp', payload.temp);
return true;
Next make a flow with the received MQTT as the trigger AND (this) Homeyscript with argument (MQTT message) THEN Populate the fields of the VD.
My flow can be found here : https://homey.app/nl-nl/flow/KuTtCM/
To clarify, if I create a virtual sensor with 4 sub-sensors, lets say; battery, humidity, temperature and pressure I need to create 4 flows what i'd like to see is the option of sending a json containing the above and that I can add 4 "then cards" where I can specify which part of the json to use, similarly to how "better logic" has this using $.json_key.optional_sub_key
How would this then work? the simplest i would think be to update the then-card with an extra field for the json, but another solution could be a new card which has 4 fields, 1 for the json (tag), 1 to select the virtual device, 1 to set the thing we want to update (e.g. measure_temperature) and the last one for the "$.json_key"