Bjoern
February 17, 2023, 12:46pm
1
Hello,
I have a hichi ir for reading my Powermeter over ir and it include tasmota over Wlan.
I have made a script, i think mqqt is working because console Output is show, but the Internal Generic Sensor Shows nothing i want connect mqtt Power_curr to a Sensor State…
Need help please
import QtQuick 2.0
import nymea 1.0
Item {
ThingEvent {
thingId: “{000861db-39b1-4e78-ba73-df3d1c905205}” // Internal MQTT client
eventName: “triggered”
onTriggered: {
console.log(“MQTT event reveived:”, JSON.stringify(params));
temp1.value = params[“'Power_curr'”]
}
}
ThingState {
id:temp1
thingId: “{7196a5db-4270-4030-bd64-b3822ac0d67e}” // Generic smart meter producer
stateName: “input”
}
}
MQTT received from tasmota mqtt in nymea:
Internal MQTT client - Publish received - tele/tasmota_DB8CCA/SENSOR, {“Time”:“2023-02-17T13:47:57”,“Haus”:{“Total_in”:274.97,“Total_out”:5.65,“Power_curr”:16,“Meter_Number”:“0a014b464d000001f8df”}}
Hi @Bjoern ,
I think you need
temp1.value = params["Haus"]["Power_curr"]
This is more obvious when formatting the json properly:
{
“Time”:“2023-02-17T13:47:57”,
“Haus”:{
“Total_in”:274.97,
“Total_out”:5.65,
“Power_curr”:16,
“Meter_Number”:“0a014b464d000001f8df”
}
}
1 Like
Bjoern
February 17, 2023, 2:54pm
3
Hi @mzanetti
It Is not working, what do i wrong? I tested temp Sensors but its a Generic producer… Im new to all these Things ^^
I only want to use a Thig that i can bind in my Power Switches if the producer count positive energy to turn on and if nothing is produced off…
9: MQTT event reveived: {“27ec8baf-0c13-4d0a-aaee-313582592695”:“tele/tasmota_DB8CCA/SENSOR”,“8af98566-79d9-4e65-b1dc-9067e4f93af1”:“{"Time":"2023-02-17T16:01:27","Haus":{"Total_in":275.11,"Total_out":5.65,"Power_curr":95,"Meter_Number":"0a014b464d000001f8df"}}”,“data”:“{"Time":"2023-02-17T16:01:27","Haus":{"Total_in":275.11,"Total_out":5.65,"Power_curr":95,"Meter_Number":"0a014b464d000001f8df"}}”,“topic”:“tele/tasmota_DB8CCA/SENSOR”}
10: TypeError: Cannot read property ‘Power_curr’ of undefined
Try
var payload = JSON.parse(params["data"])
temp1.value = payload["Haus"]["Power_curr"]
1 Like
Bjoern
February 21, 2023, 6:41pm
5
Thank you very much for your help!
But its now this error
11: TypeError: Cannot read property ‘Power_curr’ of undefined
9: MQTT event reveived: {“27ec8baf-0c13-4d0a-aaee-313582592695”:“tele/tasmota_DB8CCA/SENSOR”,“8af98566-79d9-4e65-b1dc-9067e4f93af1”:“{"Time":"2023-02-21T19:34:57","Haus":{"Total_in":287.38,"Total_out":5.95,"Power_curr":92,"Meter_Number":"0a014b464d000001f8df"}}”,“data”:“{"Time":"2023-02-21T19:34:57","Haus":{"Total_in":287.38,"Total_out":5.95,"Power_curr":92,"Meter_Number":"0a014b464d000001f8df"}}”,“topic”:“tele/tasmota_DB8CCA/SENSOR”}
Bjoern
February 21, 2023, 9:26pm
6
I have forgot to Chang the “Input” at the end to currentPower…
now its running
! Thank you!
1 Like