Help getting started with scripts

Hi,
I’m new to openHAB and its scripting. I come from Domoticz and ‘Blockly’ rules.

My Domoticz system had the following rules;

“On smoke alarm Turn On all lights and sound siren”

“On motion turn on lights but only if Lux is below 8”

“Turn lights off if no motion or Lux above 12 - but only if no smoke alarm”

“Set Nest Termostat to ‘eco’ if either front or back door is open for longer then 10 seconds”

These are fairly simple scripts but I thought I’d start with the simplest (set nest to eco) but I am failing totally. As the door sensors have a nul state when the system starts I though I would test for the door state not equalling OPEN this seems to work but it doesn’t set the Nest Thermostat to eco.

This is the script - any advice?


rule "Thermostat to eco"
when
Item Security_Door_Front changed
then
if (Security_Door_Front.state != CLOSED)
       {NestTStat_hvac_mode.sendCommand("eco")}
       else
      {NestTStat_hvac_mode.sendCommand("heating")}
end

That seems correct. Please post the item-file.
Does Security_Door_Front changed else

when
    System started or
    Item Security_Door_Front changed
then

Here is the relevent items file

Contact Security_Door_Front "FrontDoor is: [%s]" <frontdoor> { channel="zwave:device:637f1a0f:node7:sensor_door" }

String NestTStat_hvac_mode "Heating Mode [%s]" { nest="=[thermostats(Living Room).hvac_mode]" }

This is what is being logged. The Thermostat never changes to eco

2018-07-31 15:35:19.815 [vent.ItemStateChangedEvent] - Security_Door_Front changed from NULL to OPEN

2018-07-31 15:35:20.187 [ome.event.ItemCommandEvent] - Item 'NestTStat_hvac_mode' received command heating

2018-07-31 15:35:20.192 [vent.ItemStateChangedEvent] - NestTStat_hvac_mode changed from NULL to heating

2018-07-31 15:35:22.834 [me.event.ThingUpdatedEvent] - Thing 'zwave:device:657f1a0f:node7' has been updated.

2018-07-31 15:35:22.996 [vent.ItemStateChangedEvent] - Security_Door_Front changed from OPEN to CLOSED

2018-07-31 15:35:23.012 [ome.event.ItemCommandEvent] - Item 'NestTStat_hvac_mode' received command eco

2018-07-31 15:35:23.018 [vent.ItemStateChangedEvent] - NestTStat_hvac_mode changed from heating to eco

The rule works, it must be in

{ nest="=[thermostats(Living Room).hvac_mode]" }

Yes, this the old nest binding that doesn’t work anymore, you must use the 2.0 version and the channels

When using the channel it logs;

`2018-07-31 16:22:56.619 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.nest.handler.NestThermostatHandler@b347c': No enum constant org.openhab.binding.nest.internal.data.Thermostat.Mode.heating`

??? It has been working for me just fine.

It stopped working for me but maybe I was playing around with the nest permissions and api with a python script. The 2.0 binding works fine too. More stable I find.

Got it working using the channel. The reason for the error was the parameters I pass to it should have been uppercase.

Thanks to all for the help.

1 Like