Makerlife Weatherstation through MQTT
Moderator: leecollings
Makerlife Weatherstation through MQTT
Hi!
Im trying to get my Makerlife Weatherstation to work with Domoticz.
I have tried this script: https://github.com/kobbas/mqttweather
and a MQTT broker that is connected with Domoticz.
Then i added Dummy Hardware in Domoticz
But thats as far as i can get, how do i get the information from MQTT to the Dummy?
I have no experience with JSON and thats where im stuck i guess.
Or can i do this some other way?
Im trying to get my Makerlife Weatherstation to work with Domoticz.
I have tried this script: https://github.com/kobbas/mqttweather
and a MQTT broker that is connected with Domoticz.
Then i added Dummy Hardware in Domoticz
But thats as far as i can get, how do i get the information from MQTT to the Dummy?
I have no experience with JSON and thats where im stuck i guess.
Or can i do this some other way?
Re: Makerlife Weatherstation through MQTT
You have to publish your messages to topic 'domoticz/in' and the idx in the JSON determines which dummy device will be updated. I'm not 100% sure if you can update every dummy device using MQTT. Have a look at: https://www.domoticz.com/wiki/MQTT
Re: Makerlife Weatherstation through MQTT
How exactly do i do that? Could you describe for a dummieSweetPants wrote: ↑Monday 29 April 2019 8:21 You have to publish your messages to topic 'domoticz/in' and the idx in the JSON determines which dummy device will be updated. I'm not 100% sure if you can update every dummy device using MQTT. Have a look at: https://www.domoticz.com/wiki/MQTT
Re: Makerlife Weatherstation through MQTT
Did you take a look at the Wiki? It's all in thereEmpha88 wrote: ↑Monday 29 April 2019 9:15How exactly do i do that? Could you describe for a dummieSweetPants wrote: ↑Monday 29 April 2019 8:21 You have to publish your messages to topic 'domoticz/in' and the idx in the JSON determines which dummy device will be updated. I'm not 100% sure if you can update every dummy device using MQTT. Have a look at: https://www.domoticz.com/wiki/MQTT
Re: Makerlife Weatherstation through MQTT
Yes, Should i use NODE-Red to edit messages?SweetPants wrote: ↑Monday 29 April 2019 10:00Did you take a look at the Wiki? It's all in thereEmpha88 wrote: ↑Monday 29 April 2019 9:15How exactly do i do that? Could you describe for a dummieSweetPants wrote: ↑Monday 29 April 2019 8:21 You have to publish your messages to topic 'domoticz/in' and the idx in the JSON determines which dummy device will be updated. I'm not 100% sure if you can update every dummy device using MQTT. Have a look at: https://www.domoticz.com/wiki/MQTT
Re: Makerlife Weatherstation through MQTT
"2019-04-30 15:43:07.776 MQTT: Topic: domoticz/in, Message: {"temperature": 28.75, "rain": 0.2794, "windspeed": 0.6628257844249887}
2019-04-30 15:43:07.777 Error: MQTT: unknown idx received! (idx 0)"
This is what my log says right now, i change the "mqtt_c.publish('outside/weather/',payload)" to "mqtt_c.publish('domoticz/in',payload)
How do i connect the data to the right dummy device?
2019-04-30 15:43:07.777 Error: MQTT: unknown idx received! (idx 0)"
This is what my log says right now, i change the "mqtt_c.publish('outside/weather/',payload)" to "mqtt_c.publish('domoticz/in',payload)
How do i connect the data to the right dummy device?
Re: Makerlife Weatherstation through MQTT
I think you are missing the "idx":<idx> in your JSON string. Domoticz does not know now which device to update.
Something like this {"temperature": 28.75, "rain": 0.2794, "idx:" 123, "windspeed": 0.6628257844249887}
use the idx from the dummy device in the above JSON. you can find it in the device list "Setup->Devices"
BTW, i am not sure if you did read the Wiki or understand it. The above JSON is not valid. Depending on the device_type, you should use nvalue or svalue to update a device like:
{
"command": "udevice",
"idx" : 7,
"nvalue" : 0,
"svalue" : "90;2975.00"
}
Re: Makerlife Weatherstation through MQTT
Thanks! Did what you said, then i get this:SweetPants wrote: ↑Tuesday 30 April 2019 16:02I think you are missing the "idx":<idx> in your JSON string. Domoticz does not know now which device to update.
Something like this {"temperature": 28.75, "rain": 0.2794, "idx:" 123, "windspeed": 0.6628257844249887}use the idx from the dummy device in the above JSON. you can find it in the device list "Setup->Devices"
BTW, i am not sure if you did read the Wiki or understand it. The above JSON is not valid. Depending on the device_type, you should use nvalue or svalue to update a device like:
{
"command": "udevice",
"idx" : 7,
"nvalue" : 0,
"svalue" : "90;2975.00"
}
"2019-04-30 16:14:44.418 MQTT: Topic: domoticz/in, Message: {"rain": 0.2794, "temperature": 27.875, "idx": 11, "windspeed": 0.4492980149457978}
2019-04-30 16:14:44.419 Error: MQTT: Invalid data received!"
Re: Makerlife Weatherstation through MQTT
"while True:
sleep (interval)
speed.append(wind(interval))
i += 1
if i == 15:
temper = temperature()
speed_avg = sum(speed,0.00)/len(speed)
payload=json.dumps({"rain":rain_cum,
"temperature":temper,
"windspeed":speed_avg,
"idx":11})
mqtt_c.publish('domoticz/in',payload)
# print('Publish data: ' + payload)
i=0
speed.clear()
else:
pass"
Guessing i have to change some names of the sensors to get it to work with the right dummy sensor.
sleep (interval)
speed.append(wind(interval))
i += 1
if i == 15:
temper = temperature()
speed_avg = sum(speed,0.00)/len(speed)
payload=json.dumps({"rain":rain_cum,
"temperature":temper,
"windspeed":speed_avg,
"idx":11})
mqtt_c.publish('domoticz/in',payload)
# print('Publish data: ' + payload)
i=0
speed.clear()
else:
pass"
Guessing i have to change some names of the sensors to get it to work with the right dummy sensor.
Re: Makerlife Weatherstation through MQTT
"2019-04-30 17:29:45.464 MQTT: Topic: domoticz/in, Message: {"idx": 11, "svalue": "WB;WD;WS;WG;22;24", "command": "udevice", "nvalue": 0}"
So this is were im stuck right now, were do i put in the data i get from my windsensor?
tried putting the speed_avg everywhere wich is my data for the windsensor but ends up with error.
So this is were im stuck right now, were do i put in the data i get from my windsensor?
tried putting the speed_avg everywhere wich is my data for the windsensor but ends up with error.
Re: Makerlife Weatherstation through MQTT
Weather information is made of several different Dummy Sensors (multiple idx). There is no such thing as a single Weather device you can update. You have to create multiple devices and update accordingly (like the WIki Says). Different type of sensors have different update methodes.Empha88 wrote: ↑Tuesday 30 April 2019 17:31 "2019-04-30 17:29:45.464 MQTT: Topic: domoticz/in, Message: {"idx": 11, "svalue": "WB;WD;WS;WG;22;24", "command": "udevice", "nvalue": 0}"
So this is were im stuck right now, were do i put in the data i get from my windsensor?
tried putting the speed_avg everywhere wich is my data for the windsensor but ends up with error.
Like for a Temp+Humidity device, the JSON is: '{"idx":184,"nvalue":0,"svalue":"20.2;50;2"}'
where:
20.2 = Temperature
50 = Humidity (percentage)
2 = Humidity Status (0=normal, 1=Comfortable, 2=Dry, 3=Wet)
- FireWizard
- Posts: 1745
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Makerlife Weatherstation through MQTT
Hi,
Reading this thread I don't think this way it is going to work.
However it is quite easy.
In general it is a bad idea to publish messages from external equipment directly into domoticz/in, because the syntax used by the external equipment will not match the syntax expected by Domoticz.
I assume, as I read it, this weather station will transmit a message every 5 minutes and it will look like {"temperature": 28.75, "rain": 0.2794, "windspeed": 0.6628257844249887}. As SweetPants already indicated Domoticz expects something else and it is dependent on the type of sensor.
As I see in the script the weather station gives you 3 sensors:
1. Temperature Sensor (°C)
2. Wind speed (m/s)
3. Rain (mm)
Although that you have the possibility of creating a combined sensor, I recommend to create one virtual sensor for each of the sensors of the weather station. So totally three sensors of the type, resp. Temperature, Wind and Rain. You can create a combined sensor for Wind+Temp+Chill, but in that case you have to calculate the chill. As said not recommended.
So first step is to create the MQTT hardware device.
If you have installed your MQTT broker on the same hardware device as Domoticz you may use "localhost", otherwise fill in the IP address of the broker.
For security reasons I recommend at least to use a username and password combination. You have to set this in your broker as well.
Domoticz will subscribe to domoticz/in and publish to domoticz/out.
I assume that your MQTT broker (Mosquitto?) is properly installed.
If so you should see a lot of messages published to domoticz/out if you connect to the broker with a suitable client.
One I can recommend is MQTTfx (https://mqttfx.jensd.de).
The next step you should do is to reverse all the changes you have made in the weather.py file.
Or if you are not sure what has been changed re-install it.
The only thing you should modify in that file weather.py is the following:
1. Line 15: Your username and Your password (if you have set a username/password in your broker!)
2. Line 16: Your IP address (or localhost if the broker and the python script runs on the same hardware)
Do NOT change the phrase outside/weather, anywhere in the file.
If you run the script as indicated in the readme file you should be able to subscribe with e.g. MQTTfx to the topic outside/weather.
If everything is alright you will receive something like {"temperature": 28.75, "rain": 0.2794, "windspeed": 0.6628257844249887}
However as Sweetpants also said Domoticz expects another syntax for the sensors.
See: https://www.domoticz.com/wiki/Domoticz_ ... emperature
The following syntax is required:
For the Temperature Sensor:
Temperature:
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
TEMP = Temperature
For the Wind Speed sensor:
Wind
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=WB;WD;WS;WG;22;24
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
WB = Wind bearing (0-359)
WD = Wind direction (S, SW, NNW, etc.)
WS = 10 * Wind speed [m/s]
WG = 10 * Gust [m/s]
22 = Temperature
24 = Temperature Windchill
For the Rain Sensor:
Rain
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=RAINRATE;RAINCOUNTER
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
RAINRATE = amount of rain in last hour in [mm x 100]
RAINCOUNTER = continues counter of fallen Rain in [mm]
As an example if you want to send the temperature from the MQTT broker to Domoticz use the following JSON commands:
{
"command": "udevice",
"idx" : 7,
"nvalue" : 0,
"svalue" : "28,75"
}
If you don't have a value insert 0 (zero), otherwise your database may get corrupted.
So you have to convert your payload (message) from the weather station to something above that Domoticz recognizes.
To do that, you have 2 options:
1. If you are a programmer then you can use a scripting language, like LUA, dzVents, Python or PHP or whatever.
2. If you don't feel comfortable in those scripting languages, use Node-Red, as already suggested.
With Node-Red such a conversion is more or less straight forward.
If you don't have NodeJS and Node-Red already installed, install it with the following instructions:
NodeJS: https://www.instructables.com/id/Instal ... pberry-Pi/
Node-RED: https://nodered.org/docs/getting-started/installation
If you need further support with the conversion in Node-Red don't hesitate to ask, but publish your results so far.
Reading this thread I don't think this way it is going to work.
However it is quite easy.
In general it is a bad idea to publish messages from external equipment directly into domoticz/in, because the syntax used by the external equipment will not match the syntax expected by Domoticz.
I assume, as I read it, this weather station will transmit a message every 5 minutes and it will look like {"temperature": 28.75, "rain": 0.2794, "windspeed": 0.6628257844249887}. As SweetPants already indicated Domoticz expects something else and it is dependent on the type of sensor.
As I see in the script the weather station gives you 3 sensors:
1. Temperature Sensor (°C)
2. Wind speed (m/s)
3. Rain (mm)
Although that you have the possibility of creating a combined sensor, I recommend to create one virtual sensor for each of the sensors of the weather station. So totally three sensors of the type, resp. Temperature, Wind and Rain. You can create a combined sensor for Wind+Temp+Chill, but in that case you have to calculate the chill. As said not recommended.
So first step is to create the MQTT hardware device.
If you have installed your MQTT broker on the same hardware device as Domoticz you may use "localhost", otherwise fill in the IP address of the broker.
For security reasons I recommend at least to use a username and password combination. You have to set this in your broker as well.
Domoticz will subscribe to domoticz/in and publish to domoticz/out.
I assume that your MQTT broker (Mosquitto?) is properly installed.
If so you should see a lot of messages published to domoticz/out if you connect to the broker with a suitable client.
One I can recommend is MQTTfx (https://mqttfx.jensd.de).
The next step you should do is to reverse all the changes you have made in the weather.py file.
Or if you are not sure what has been changed re-install it.
The only thing you should modify in that file weather.py is the following:
1. Line 15: Your username and Your password (if you have set a username/password in your broker!)
2. Line 16: Your IP address (or localhost if the broker and the python script runs on the same hardware)
Do NOT change the phrase outside/weather, anywhere in the file.
If you run the script as indicated in the readme file you should be able to subscribe with e.g. MQTTfx to the topic outside/weather.
If everything is alright you will receive something like {"temperature": 28.75, "rain": 0.2794, "windspeed": 0.6628257844249887}
However as Sweetpants also said Domoticz expects another syntax for the sensors.
See: https://www.domoticz.com/wiki/Domoticz_ ... emperature
The following syntax is required:
For the Temperature Sensor:
Temperature:
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
TEMP = Temperature
For the Wind Speed sensor:
Wind
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=WB;WD;WS;WG;22;24
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
WB = Wind bearing (0-359)
WD = Wind direction (S, SW, NNW, etc.)
WS = 10 * Wind speed [m/s]
WG = 10 * Gust [m/s]
22 = Temperature
24 = Temperature Windchill
For the Rain Sensor:
Rain
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=RAINRATE;RAINCOUNTER
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
RAINRATE = amount of rain in last hour in [mm x 100]
RAINCOUNTER = continues counter of fallen Rain in [mm]
As an example if you want to send the temperature from the MQTT broker to Domoticz use the following JSON commands:
{
"command": "udevice",
"idx" : 7,
"nvalue" : 0,
"svalue" : "28,75"
}
If you don't have a value insert 0 (zero), otherwise your database may get corrupted.
So you have to convert your payload (message) from the weather station to something above that Domoticz recognizes.
To do that, you have 2 options:
1. If you are a programmer then you can use a scripting language, like LUA, dzVents, Python or PHP or whatever.
2. If you don't feel comfortable in those scripting languages, use Node-Red, as already suggested.
With Node-Red such a conversion is more or less straight forward.
If you don't have NodeJS and Node-Red already installed, install it with the following instructions:
NodeJS: https://www.instructables.com/id/Instal ... pberry-Pi/
Node-RED: https://nodered.org/docs/getting-started/installation
If you need further support with the conversion in Node-Red don't hesitate to ask, but publish your results so far.
Last edited by FireWizard on Saturday 04 May 2019 22:25, edited 2 times in total.
Re: Makerlife Weatherstation through MQTT
Oh, this is just what i need, gonna try it this weekend, will come back with the results, BIG thank you!FireWizard wrote: ↑Wednesday 01 May 2019 18:18 Hi,
Reading this thread I don't think this way it is going to work.
However it is quite easy.
In general it is a bad idea to publish messages from external equipment directly into domoticz/in, because the syntax used by the external equipment will not match the syntax expected by Domoticz.
I assume, as I read it, this weather station will transmit a message every 5 minutes and it will look like {"temperature": 28.75, "rain": 0.2794, "windspeed": 0.6628257844249887}. As SweetPants already indicated Domoticz expects something else and it is dependent on the type of sensor.
As I see in the script the weather station gives you 3 sensors:
1. Temperature Sensor (°C)
2. Wind speed (m/s)
3. Rain (mm)
Although that you have the possibility of creating a combined sensor, I recommend to create one virtual sensor for each of the sensors of the weather station. So totally three sensors of the type, resp. Temperature, Wind and Rain. You can create a combined sensor for Wind+Temp+Chill, but in that case you have to calculate the chill. As said not recommended.
So first step is to create the MQTT hardware device.
MQTT Domoticz.png
If you have installed your MQTT broker on the same hardware device as Domoticz you may use "localhost", otherwise fill in the IP address of the broker.
For security reasons I recommend at least to use a username and password combination. You have to set this in your broker as well.
Domoticz will subscribe to domoticz/in and publish to domoticz/out.
I assume that you MQTT broker (Mosquitto?) is properly installed.
If so you should see a lot of messages published to domoticz/out if you connect to the broker with a suitable client.
One I can recommend is MQTTfx (https://mqttfx.jensd.de).
The next step you should do is to reverse all the changes you have made in the weather.py file.
Or if you are not sure what has been changed re-install it.
The only thing you should modify in that file weather.py is the following:
1. Line 15: Your username and Your password (if you have set a username/password in your broker!)
2. Line 16: Your IP address (or localhost if the broker and the python script runs on the same hardware)
Do NOT change the phrase outside/weather, anywhere in the file.
If you run the script as indicated in the readme file you should be able to subscribe with e.g. MQTTfx to the topic outside/weather.
If everything is alright you will receive something like {"temperature": 28.75, "rain": 0.2794, "windspeed": 0.6628257844249887}
However as Sweetpant also said Domoticz expects another syntax for the sensors.
See: https://www.domoticz.com/wiki/Domoticz_ ... emperature
The following syntax is required:
For the Temperature Sensor:
Temperature:
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
TEMP = Temperature
For the Wind Speed sensor:
Wind
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=WB;WD;WS;WG;22;24
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
WB = Wind bearing (0-359)
WD = Wind direction (S, SW, NNW, etc.)
WS = 10 * Wind speed [m/s]
WG = 10 * Gust [m/s]
22 = Temperature
24 = Temperature Windchill
For the Rain Sensor:
Rain
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=RAINRATE;RAINCOUNTER
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
RAINRATE = amount of rain in last hour in [mm x 100]
RAINCOUNTER = continues counter of fallen Rain in [mm]
As an example if you want to send the temperature from the MQTT broker to Domoticz use the following JSON commands:
{
"command": "udevice",
"idx" : 7,
"nvalue" : 0,
"svalue" : "28,75"
}
If you don't have a value insert 0 (zero), otherwise your database may get corrupted.
So you have to convert your payload (message) from the weather station to something above that Domoticz recognizes.
To do that, you have 2 options:
1. If you are a programmer then you can use a scripting language, like LUA, dzVents, Python or PHP or whatever.
2. If you don't feel comfortable in those scripting languages, use Node-Red, as already suggested.
With Node-Red such a conversion is more or less straight forward.
If you don't have NodeJS and Node-Red already installed, install it with the following instructions:
NodeJS: https://www.instructables.com/id/Instal ... pberry-Pi/
Node-RED: https://nodered.org/docs/getting-started/installation
If you need further support with the conversion in Node-Red don't hesitate to ask, but publish your results so far.
Who is online
Users browsing this forum: No registered users and 0 guests