Page 1 of 1

Virtual Sensor test

Posted: Tuesday 15 November 2016 19:17
by mbursteing
Hi,

I'm trying to test mqtt protocol with Domoticz. For that I'm using a BeagleBone Black with mosquitto that takes a value from a existing sensor in Domoticz with JSON, and send this value over MQTT to Domoticz to a virtual sensor. the problem is that I'm not getting any value on the virtual sensor. I'm using a shell script

Code: Select all


#!/bin/bash

while true
do
value=$(python -c 'import sensorValue; print sensorValue.sensor_value(8)')
mosquitto_pub -h 192.168.1.13 -m '{ "idx" : 13, "nvalue" : 0, "svalue" : "$value" }' -t 'domoticz/$
sleep 1
done 
This code is running well cuz Domoticz virtual sensor updates every minute, but with no value. Thanks.

Regards,
Marcelo

ps: sensorValue is a function that takes the value of an specific sensor on Domoticz. In this case idx=8

Re: Virtual Sensor test

Posted: Tuesday 15 November 2016 21:25
by mbursteing
Whats' the differenco of usin ' ' and using " ", cuz when I test the mqtt message sent using anoter suscriber I can see that the received message is good, I can see the sensor value, but why Domoticz can't see it?

Re: Virtual Sensor test

Posted: Friday 18 November 2016 19:56
by mbursteing
Any help?

when I use this command

Code: Select all

mosquitto_pub -h 192.168.1.13 -m "{ "idx" : 13, "nvalue" : 0, "svalue" : "$value" }" -t "domoticz/in" 
I can't change the sensor value. But, when I use single quotes like this:

Code: Select all

mosquitto_pub -h 192.168.1.13 -m '{ "idx" : 13, "nvalue" : 0, "svalue" : "$value" }' -t "domoticz/in" 
I can. the problem is that it doesn't get any value cuz the single quotes allows only strings

Re: Virtual Sensor test

Posted: Thursday 24 November 2016 19:13
by fets
Inside single quotes, variables are not interpreted. So you need to use double and bachslash each double quote as this :
mosquitto_pub -h 192.168.1.13 -m "{ \"idx\" : 13, \"nvalue\" : 0, "svalue\" : \"$value\" }" -t "domoticz/in"