fhem http support
Moderators: grovkillen, Stuntteam, TD-er
fhem http support
Hi,
I'm using them as domotica software. It should be nice to also have that supported.
I have an example of lua how I post it to fhem. It looks like domoticz post. It's based on a si7021 i2c sensor
tmr.alarm(0, 90000, 1, function()
SDA_PIN = 3 -- sda pin, GPIO0
SCL_PIN = 4 -- scl pin, GPIO2
si7021 = require("si7021")
si7021.init(SDA_PIN, SCL_PIN)
si7021.read(OSS)
h = si7021.getHumidity()/100
t = si7021.getTemperature()/100
function round(n)
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
end
hum = tonumber(string.format("%." .. (1) .. "f", h))
hum = round(hum)
temp = tonumber(string.format("%." .. (1) .. "f", t))
-- release module
si7021 = nil
package.loaded["si7021"]=nil
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end )
conn:connect(8083,"192.168.180.5")
conn:send('GET /fhem?cmd=setreading%20Slaapkamertemp%20state%20T:%20' ..temp.. '%20H:%20'..hum..'\r\n HTTP/1.1\r\nHost: www.local.lan\r\n".."Connection: keep-alive\r\nAccept: */*\r\n\r\n"')
end)
I'm using them as domotica software. It should be nice to also have that supported.
I have an example of lua how I post it to fhem. It looks like domoticz post. It's based on a si7021 i2c sensor
tmr.alarm(0, 90000, 1, function()
SDA_PIN = 3 -- sda pin, GPIO0
SCL_PIN = 4 -- scl pin, GPIO2
si7021 = require("si7021")
si7021.init(SDA_PIN, SCL_PIN)
si7021.read(OSS)
h = si7021.getHumidity()/100
t = si7021.getTemperature()/100
function round(n)
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
end
hum = tonumber(string.format("%." .. (1) .. "f", h))
hum = round(hum)
temp = tonumber(string.format("%." .. (1) .. "f", t))
-- release module
si7021 = nil
package.loaded["si7021"]=nil
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end )
conn:connect(8083,"192.168.180.5")
conn:send('GET /fhem?cmd=setreading%20Slaapkamertemp%20state%20T:%20' ..temp.. '%20H:%20'..hum..'\r\n HTTP/1.1\r\nHost: www.local.lan\r\n".."Connection: keep-alive\r\nAccept: */*\r\n\r\n"')
end)
Re: fhem http support
Hi,
I now tried it with mqtt to fhem. That works a little. I get this in fhem (when using the domotiqz mqtt)
start {"idx":2,"nvalue":0,"svalue":"19.96;74.00;0"}
2015-11-08 20:46:52 transmission-state incoming publish received
I get this as value: {"idx":2,"nvalue":0,"svalue":"19.96;74.00;0"}
Is there a way to only get: 19.96 74.00 or T 19.96 H 74.00
Than it should be simple to get it working
Regards Richard
I now tried it with mqtt to fhem. That works a little. I get this in fhem (when using the domotiqz mqtt)
start {"idx":2,"nvalue":0,"svalue":"19.96;74.00;0"}
2015-11-08 20:46:52 transmission-state incoming publish received
I get this as value: {"idx":2,"nvalue":0,"svalue":"19.96;74.00;0"}
Is there a way to only get: 19.96 74.00 or T 19.96 H 74.00
Than it should be simple to get it working
Regards Richard
Re: fhem http support
Hi kroonen,
coul you tell me please how you configured the FHEM MQTT_Device?
I can't read anything in FHEM up to now.
Thanks!
BR
Niklas
coul you tell me please how you configured the FHEM MQTT_Device?
I can't read anything in FHEM up to now.
Thanks!
BR
Niklas
Re: fhem http support
Niklas,
Make tins working in them
define mqtt MQTT 127.0.0.1:1883
define mqtt_testtemp MQTT_DEVICE testtemp
attr mqtt_testtemp subscribeReading_start fhem/temp
And try with local mosquito tool on them server
mosquitto_pub -t fhem/temp -m test
Than choose in espeasy, domoticz mqtt, and choose port 1883, and ip adds where your fhem/mqtt stands
than on tools advanced. mutt publish template to fhem/temp
than you get those readings
regards Richard
Make tins working in them
define mqtt MQTT 127.0.0.1:1883
define mqtt_testtemp MQTT_DEVICE testtemp
attr mqtt_testtemp subscribeReading_start fhem/temp
And try with local mosquito tool on them server
mosquitto_pub -t fhem/temp -m test
Than choose in espeasy, domoticz mqtt, and choose port 1883, and ip adds where your fhem/mqtt stands
than on tools advanced. mutt publish template to fhem/temp
than you get those readings
regards Richard
Re: fhem http support
Hi Richard,
I tried exactly what you wrote.
With the local try and with an Android MQTT App it is working, but my ESPEasy always tells me "Failed to connected to broker".
Tere still seems to be something wrong.
BR
Niklas
I tried exactly what you wrote.
With the local try and with an Android MQTT App it is working, but my ESPEasy always tells me "Failed to connected to broker".
Tere still seems to be something wrong.
BR
Niklas
Re: fhem http support
Niklas,
You change controller port to 1883?
and protocol to domotcz mqtt
and on advanced config the publish template to the right topic for example fhem/temp?
and did a submit and checked the values
regards richard
You change controller port to 1883?
and protocol to domotcz mqtt
and on advanced config the publish template to the right topic for example fhem/temp?
and did a submit and checked the values
regards richard
Re: fhem http support
Maybe you can try the Pidome configuration where single values are published instead of json format.kroonen wrote:Is there a way to only get: 19.96 74.00 or T 19.96 H 74.00
Regards Richard
It should publish each individual value.
Re: fhem http support
You are right, that al the values are separate pushed. I asked in fhem forum how to create sensors for this
http://forum.fhem.de/index.php/topic,43669.0.html
http://forum.fhem.de/index.php/topic,43669.0.html
Re: fhem http support
What template are you using in MQTT publish?kroonen wrote:You are right, that al the values are separate pushed. I asked in fhem forum how to create sensors for this
http://forum.fhem.de/index.php/topic,43669.0.html
Re: fhem http support
I change the template to fhem/temp
because else I get nog values?
Or should I name the mqtt broker different? Now i call it in fhem
subscribeReading_start fhem/temp
Now I get the values like this
2015-11-15_15:35:02 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:02 mqtt_testtemp start: 19.69
2015-11-15_15:35:02 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:02 mqtt_testtemp start: 1012.95
2015-11-15_15:35:03 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:03 mqtt_testtemp start: 19.57
2015-11-15_15:35:03 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:03 mqtt_testtemp start: 66.00
It should be nice to have it like this
2015-11-15_15:35:02 mqtt_testtemp start: 19.69 1012.95 19.57 66.00
Than I can strip it in fhem
because else I get nog values?
Or should I name the mqtt broker different? Now i call it in fhem
subscribeReading_start fhem/temp
Now I get the values like this
2015-11-15_15:35:02 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:02 mqtt_testtemp start: 19.69
2015-11-15_15:35:02 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:02 mqtt_testtemp start: 1012.95
2015-11-15_15:35:03 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:03 mqtt_testtemp start: 19.57
2015-11-15_15:35:03 mqtt_testtemp transmission-state: incoming publish received
2015-11-15_15:35:03 mqtt_testtemp start: 66.00
It should be nice to have it like this
2015-11-15_15:35:02 mqtt_testtemp start: 19.69 1012.95 19.57 66.00
Than I can strip it in fhem
Re: fhem http support
I think you need something like these samples:
/%sysname%/%tskname%/%valname%
/hooks/devices/%id%/SensorData/%valname%
or else all values would be published on the same channel and you will not be able to tell which is which.
Domoticz uses json over mqtt so json tells all information about the device. If we publish single values, they should be on different channels.
So it guess it could be something like:
/fhem/esp1/livingroom/temperature
/fhem/esp1/livingroom/humidity
/fhem/esp1/kitchen/temperature
/fhem/esp2/shed/temperature
/fhem/esp1/shed/humidity
where fhem controller should listen to /fhem/#
If you check with openhab of pidome, each device listens to a specific published channel.
/%sysname%/%tskname%/%valname%
/hooks/devices/%id%/SensorData/%valname%
or else all values would be published on the same channel and you will not be able to tell which is which.
Domoticz uses json over mqtt so json tells all information about the device. If we publish single values, they should be on different channels.
So it guess it could be something like:
/fhem/esp1/livingroom/temperature
/fhem/esp1/livingroom/humidity
/fhem/esp1/kitchen/temperature
/fhem/esp2/shed/temperature
/fhem/esp1/shed/humidity
where fhem controller should listen to /fhem/#
If you check with openhab of pidome, each device listens to a specific published channel.
Re: fhem http support
I can use that so what value is what?
Using pidome mqtt
/fhem/%id%/%valname% is that is correct that /fhem/idx/Temperature for this?
So fhem/1/Temperature for test?
So is %id% the idx/variable?
regards Richard
Using pidome mqtt
/fhem/%id%/%valname% is that is correct that /fhem/idx/Temperature for this?
So fhem/1/Temperature for test?
So is %id% the idx/variable?
regards Richard
Re: fhem http support
Hi Richard,
my main problem was that I could not connect to the broker due to a wrong /etc(network/interfaces configuration on my pi. Now I solved this problem and could read Temperature and Humidity separately:
ESPEasy:
set PiDome MQTT
leave Tools/System/Advanced as it is
FHEM:
define mqtt MQTT IP:Port
define mqtt_DHT22 MQTT_DEVICE
attr mqtt_DHT22 IODev mqtt
attr mqtt_DHT22 autoSubscribeReadings /hooks/devices/15/SensorData/+
attr mqtt_DHT22 stateFormat Temperatur: Temperature°C Luftfeuchtigkeit: Humidity%rH
attr mqtt_DHT22 subscribeReading_Humidity /hooks/devices/15/SensorData/Humidity
attr mqtt_DHT22 subscribeReading_Temperature /hooks/devices/15/SensorData/Temperature
I hope this helps.
my main problem was that I could not connect to the broker due to a wrong /etc(network/interfaces configuration on my pi. Now I solved this problem and could read Temperature and Humidity separately:
ESPEasy:
set PiDome MQTT
leave Tools/System/Advanced as it is
FHEM:
define mqtt MQTT IP:Port
define mqtt_DHT22 MQTT_DEVICE
attr mqtt_DHT22 IODev mqtt
attr mqtt_DHT22 autoSubscribeReadings /hooks/devices/15/SensorData/+
attr mqtt_DHT22 stateFormat Temperatur: Temperature°C Luftfeuchtigkeit: Humidity%rH
attr mqtt_DHT22 subscribeReading_Humidity /hooks/devices/15/SensorData/Humidity
attr mqtt_DHT22 subscribeReading_Temperature /hooks/devices/15/SensorData/Temperature
I hope this helps.
Re: fhem http support
Niklas,
That works . Thnx.
regards Richard
That works . Thnx.
regards Richard
Re: fhem http support
Still one question
I Want for example nog 21.07 but rounded with 1 decimal, 21.1 and for humidity you only 70 and not 70.00
Any idea if this could be in esp easy with formula, or is it possible in fhem?
regards Richard
I Want for example nog 21.07 but rounded with 1 decimal, 21.1 and for humidity you only 70 and not 70.00
Any idea if this could be in esp easy with formula, or is it possible in fhem?
regards Richard
Who is online
Users browsing this forum: Ahrefs [Bot] and 9 guests