Hi, i’m Nymea user since few months ago, i found it marvelous, thank you for your amazing job with it.
I’m already playing with the generic water level sensor, for that i’m using a hr-sr04 connected to a tasmota device to meassure the distance between the sensor and the water surface. That is working well, but wen i’m setting up Nymea things i ran into problems.
I have created the next things:
- Tasmota device.
- Internal mqtt client.
- Generic water level sensor.
After setting up the mqtt client, i created the following magic script (based on a working temp sensor):
import QtQuick 2.0
import nymea 1.0
Item {
ThingEvent {
thingId: "{060e00dd-b96e-4b05-baf6-e30b5b2c7ac7}" // Tank sensor
eventName: "triggered"
onTriggered: {
console.log("received from tank sensor:", JSON.stringify(params));
var data = JSON.parse(params["data"]);
tank1.value = data.SR04.Distance;
console.log("value: ",tank1.value," dist: ",data.SR04.Distance);
}
}
ThingState {
id: tank1
thingId: "{e761c17f-4e8a-474e-bc13-0d9f12dec91b}" // Generic water level sensor
stateName: "waterLevel"
}
}
Console log example output:
9: received from tank sensor: {"27ec8baf-0c13-4d0a-aaee-313582592695":"24c87bc3bcdd4d46b05d4b96a39ab581/sonoff/SENSOR","8af98566-79d9-4e65-b1dc-9067e4f93af1":"{\"Time\":\"2022-01-16T21:58:01\",\"SR04\":{\"Distance\":37.895}}","data":"{\"Time\":\"2022-01-16T21:58:01\",\"SR04\":{\"Distance\":37.895}}","topic":"24c87bc3bcdd4d46b05d4b96a39ab581/sonoff/SENSOR"}
14: value: 0 dist: 37.895
My problem is that tank1.value is always zero. I tried to put in it different values, between 0 and 1, between 0 and 100… but It always shows zero (and the sensor visualization too). I tried to change other sensors value from the same script and it works fine. But my new generic water level sensor refuses to work.
Can you help me figure out what I’m missing? Thank you in advance.