How to return current temp from my thermostat?

nope:
2015-12-20 00:42:18.454 [ERROR] [i.internal.GenericItemProvider] - Binding configuration of type ‘http’ of item ‘HeatmiserTemperatura‘ could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: bindingConfig ‘heatmiser:JSONPATH($.[‘192.168.2.251’].heating.target)’ doesn’t represent a valid in-binding-configuration. A valid configuration is matched by the RegExp ‘(.?)({.})?:(?!//)(\d*):(.*)’

sorry: you wrote: the refressh time!
going…

G R E A T!
I was fighting with the item since 4 hours…

Thanks.
Now that I got it I will finish a complete setup for Heatmiser Wifi and publish for the community.

cheers

1 Like

I am trying to get this to work properly in a more linear way…
currently I call an http and get back a json from the apache server.
All of this is sitting on the same pi.
The server to give back the json calls some perl scripts via cgi.
To get the status of all the n parameters of the thermostat I would do n calls to the server.
Not nice.

So, I am trying to do it more directly by calling the perl script just once from my rules but it does not seem to work.

Here is the piece of code:
rule “Initialization”
when
System started
then

var String status = executeCommandLine("/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh")
var String result = transform(“JSONPATH”, “$.[‘192.168.2.251’].heating.target”, status)

where hw_status.sh is the perl script returning this Json
{
“192.168.2.251” : {
“comfort” : [
[
{
“target” : 22,
“time” : “06:30:00”
},
{
“target” : 22,
“time” : “08:30:00”
},
{
“target” : 23,
“time” : “12:30:00”
},
{
“target” : 22,
“time” : “23:00:00”
}
],
[
{
“target” : 22,
“time” : “07:30:00”
},
{
“target” : 20,
“time” : “23:30:00”
}
]
],
“config” : {
“caloffset” : 0,
“locklimit” : 0,
“optimumstart” : 0,
“outputdelay” : 0,
“progmode” : “5/2”,
“sensor” : “internal”,
“switchdiff” : 1,
“units” : “C”
},
“dcblength” : 72,
“enabled” : 1,
“errorcode” : null,
“frostprotect” : {
“enabled” : 1,
“target” : 12
},
“heating” : {
“hold” : 0,
“on” : 0,
“target” : 23
},
“holiday” : {
“enabled” : 0,
“time” : “2015-12-23 20:07:00”
},
“keylock” : 0,
“product” : {
“model” : “PRT”,
“vendor” : “Heatmiser”,
“version” : 1.9
},
“rateofchange” : 20,
“runmode” : “heating”,
“temperature” : {
“floor” : null,
“internal” : 22.5,
“remote” : null
},
“time” : “2015-12-23 20:07:05”
}
}

the log:

01:46:29.978 [INFO ] [g.openhab.io.net.exec.ExecUtil:66 ] - executed commandLine ‘/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh’
01:46:30.141 [ERROR] [o.o.c.t.actions.Transformation:47 ] - Error executing the transformation ‘JSONPATH’: the given parameters ‘JSonPath’ and ‘source’ must not be null
01:46:30.290 [INFO ] [rg.openhab.model.script.result:53 ] - null
01:46:30.352 [INFO ] [g.openhab.io.net.exec.ExecUtil:66 ] - executed commandLine ‘/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh’
01:46:30.402 [ERROR] [m.r.internal.engine.RuleEngine:278 ] - Error during the execution of startup rule ‘Initialization’: Cannot create a duplicate value ‘result’.
01:46:31.222 [D

So it seems that executecommandline 's result (status) is null.
If I execute by hand on the CLI it returns the JSON

Furhermore there’s another error “Cannot create a duplicate value ‘result’.”

Any help is appreciated as usual.

Cheers.

  1. Are you sure it’s not transform("JSONPATH", "$['192.168.2.251'].heating.target", status)?

  2. Also, rename your result variable to something else, in case there is already one in the namespace.

  3. The last question is if the user running the openHAB server has the permission to execute the hw_status.sh script.

the JSONPATH was wrong (I am still learning…).
I changed the var names to something unique
However the result is not chamged

11:16:08.085 [INFO ] [g.openhab.io.net.exec.ExecUtil:66 ] - executed commandLine ‘/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh’
11:16:08.215 [ERROR] [o.o.c.t.actions.Transformation:47 ] - Error executing the transformation ‘JSONPATH’: the given parameters ‘JSonPath’ and ‘source’ must not be null
11:16:08.297 [INFO ] [g.openhab.io.net.exec.ExecUtil:66 ] - executed commandLine ‘/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh’
11:16:08.440 [ERROR] [o.o.c.t.actions.Transformation:47 ] - Error executing the transformation ‘JSONPATH’: the given parameters ‘JSonPath’ and ‘source’ must not be null
11:16:08.580 [ERROR] [o.o.c.t.actions.Transformation:47 ] - Error executing the transformation ‘JSONPATH’: the given parameters ‘JSonPath’ and ‘source’ must not be null
11:16:08.851 [WARN ] [.c.i.events.EventPublisherImpl:80 ] - given new state is NULL, couldn’t post update for ‘HW_RoomTemperature’

I am also trying to output it via
logInfo(“HM”,status)
logInfo(“HM”,result)

however in the log (I am starting in start_debug) I cannot see anything.

update:

Nothing to do…

this is my rule:
rule “Initialization”
when
System started
then
var String sta = executeCommandLine("/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh")
logInfo(“Testing”, “executecommandline”)
logInfo(“Testing”, sta)
postUpdate(dummy , sta)
var String res = transform(“JSONPATH”, “$.[‘192.168.2.251’].heating.target”, sta)
logInfo(“Testing”, “json”)
logInfo(“Testing”, res)
postUpdate(dummy , sta)

this is the log:
pi@openhab /var/opt/openhab/logs $ tail openhab.log
2015-12-30 10:22:47.373 [INFO ] [c.internal.ModelRepositoryImpl] - Refreshing model ‘hm.rules’
2015-12-30 10:22:47.575 [INFO ] [g.openhab.io.net.exec.ExecUtil] - executed commandLine ‘/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh’
2015-12-30 10:22:47.612 [INFO ] [g.openhab.model.script.Testing] - executecommandline
2015-12-30 10:22:47.658 [INFO ] [g.openhab.model.script.Testing] - null
2015-12-30 10:22:47.774 [ERROR] [o.o.c.t.actions.Transformation] - Error executing the transformation ‘JSONPATH’: the given parameters ‘JSonPath’ and ‘source’ must not be null
2015-12-30 10:22:47.810 [INFO ] [g.openhab.model.script.Testing] - json
2015-12-30 10:22:47.855 [INFO ] [g.openhab.model.script.Testing] - null
2015-12-30 10:22:47.942 [INFO ] [g.openhab.io.net.exec.ExecUtil] - executed commandLine ‘/home/pi/heatmiser-wifi-read-only/openhabscripts/hw_status.sh’
2015-12-30 10:22:48.015 [ERROR] [o.o.c.t.actions.Transformation] - Error executing the transformation ‘JSONPATH’: the given parameters ‘JSonPath’ and ‘source’ must not be null
2015-12-30 10:22:48.065 [ERROR] [o.o.c.t.actions.Transformation] - Error executing the transformation ‘JSONPATH’: the given parameters ‘JSonPath’ and ‘source’ must not be null

files are ownership of pi user and group.
openhab is run as root so…

I even changed the script to printout directly a JSON string:

more /home/pi/heatmiser-wifi-read-only/openhabscripts/t

where t is the output of the heatmiser_json_oh.pl script put on one line:

{ “192.168.2.251” : { “comfort” : [ [ { “target” : 22, “time” : “06:30:00” }, { “target” : 22, “time” : “08:30:00” }, { “target” : 23, “time” : “12:30:00” }, { “target” : 22, “time” : “23:00:00” } ], [ { “target” : 22, “time” : “07:30:00” }, { “target” : 20, “time” : “23:30:00” } ] ], “config” : { “caloffset” : 0, “locklimit” : 0, “optimumstart” : 0, “outputdelay” : 0, “progmode” : “5/2”, “sensor” : “internal”, “switchdiff” : 1, “units” : “C” }, “dcblength” : 72, “enabled” : 1, “errorcode” : null, “frostprotect” : { “enabled” : 1, “target” : 12 }, “heating” : { “hold” : 0, “on” : 0, “target” : 22 }, “holiday” : { “enabled” : 0, “time” : “2015-12-30 09:59:00” }, “keylock” : 0, “product” : { “model” : “PRT”, “vendor” : “Heatmiser”, “version” : 1.9 }, “rateofchange” : 20, “runmode” : “heating”, “temperature” : { “floor” : null, “internal” : 22, “remote” : null }, “time” : “2015-12-30 09:59:57” } }

it is clear to me that although the executecommandline is logged as executed either the output is not getting passed to the sta String variable or there is no output from the command as the sta variable is null.

but… why

Ok … Finally I found out.
I share for all : it was due to the executeCommandLine returing before getting the answer from the script.
Adding a timeout solved.

I have the same thermostat. Could you post your complete set of files? I was able to follow and get it to return the temperature and mode, but I am stuck at getting everything working like your above example.

Working on it.
I hope I can finish all the scripts in a few days.
Will finally be a working integration.
Possible to setup each and every of the parameters the app can and get the “read only” info from the Heatmiser.

I have the items and sitemap complete and am working on the logic of interface (raise / lower temp etc).

Basically what I did is follow the steps of the heatmiser wifi project (google for it).
After that I am taking as example the alarm items/sitemap in the wiki for the interface.

As soon as I have a minimally presentable thing I will post a link to a small github with the files.

Glad it will be useful for someone else too :slight_smile:

Edit: Yesterday night a substantial advancement. I hope to publish the files tonight :wink:

Have you guys had any issues with the temperature not updating because of sending too many requests? I’m having an issue and am trying to figure out if it’s because of my refresh rate.

I had a problem with losing a connection to the thermostat which I thought was from polling the thermostat too often. Originally it worked fine, but as I added lights to the system it became a problem and eventually quite annoying.

My solution was to move my installation from a Raspberry Pi to a PC that is on all the time in my office. Since moving the system off the Raspberry Pi I haven’t had any trouble with the thermostat.

Did you have a Pi or a Pi2? I thought the Pi2 was capable enough to handle this. If not, I’m sure I can adjust the polling so it doesn’t poll as much. It’s just weird that it only affects the HTTP binding and all the other data keeps working fine.

It was the Pi2. And the only thing that didn’t work consistently was HTTP to the thermostat. It would stop communicating and I would need to reboot the thermostat and it would reconnect and start working again. And a day or two later it would loose connection again.

The only thing I did to resolve was install OpenHAB on the PC and copy over my sitemap, rules, items etc to the new installation. And since making that change it hasn’t failed.

That is awesome! I will be on the lookout for it. Thanks!