Virtual Sensor test

Moderator: leecollings

Post Reply
mbursteing
Posts: 4
Joined: Wednesday 02 November 2016 21:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Virtual Sensor test

Post 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
mbursteing
Posts: 4
Joined: Wednesday 02 November 2016 21:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Virtual Sensor test

Post 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?
mbursteing
Posts: 4
Joined: Wednesday 02 November 2016 21:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Virtual Sensor test

Post 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
fets
Posts: 21
Joined: Monday 21 September 2015 20:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2969
Contact:

Re: Virtual Sensor test

Post 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"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest