Ds18b20 temp and relay control via openhab

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#11 Post by shenery » 10 May 2017, 18:57

Heres the rest of my settings
Attachments
Screenshot_20170510-175124.png
Screenshot_20170510-175124.png (61.43 KiB) Viewed 19318 times
Screenshot_20170510-175124.png
Screenshot_20170510-175124.png (61.43 KiB) Viewed 19318 times
Screenshot_20170510-175045.png
Screenshot_20170510-175045.png (192.55 KiB) Viewed 19318 times
Screenshot_20170510-172801.png
Screenshot_20170510-172801.png (112.73 KiB) Viewed 19318 times

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#12 Post by shenery » 10 May 2017, 20:36

I managed to get the temperature reading in openhab. I had the mqtt location wrong.
I have also created a .rules file in openhab which I didn't post before but still when I increase the temp in openhab my heater doesn't go on.
Attachments
Screenshot_20170510-192403.png
Screenshot_20170510-192403.png (101.55 KiB) Viewed 19312 times
Screenshot_20170510-185657.png
Screenshot_20170510-185657.png (62.73 KiB) Viewed 19312 times

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#13 Post by sheppy » 10 May 2017, 21:20

If that's the actual rule?
"//Do stuff like turn Heater OFF etc" will need replacing with
"sendCommand(Heater, OFF)"
AND
"//Do stuff like turn Heater ON etc" will need replacing with
"sendCommand(Heater, ON)"
all without the ""
also anything after // is a comment and is for information only

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#14 Post by shenery » 10 May 2017, 22:13

Ah I see. How do I get my power icon back? The heater has a lightbulb instead of a power icon. Is this because my heater item is set up as a light?

Thanks for all your help by the way. Much appreciated.

Steven

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#15 Post by sheppy » 10 May 2017, 22:19

Is this because my heater item is set up as a light?
Yes, see below for available icons, try using "fire" or "heating" as an icon and the icon will change between ON and OFF
http://docs.openhab.org/addons/iconsets ... eadme.html

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#16 Post by shenery » 11 May 2017, 08:49

Ok I've tidied things up a bit but I still can't get it to do what I want. When I have the heater on and decrease the temp the relay should switch off right? And switch back on when I increase the temp?
I can turn my heater on and off but now with temperature adjustment.
Attachments
Screenshot_20170511-074528.png
Screenshot_20170511-074528.png (93.72 KiB) Viewed 19273 times

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#17 Post by sheppy » 11 May 2017, 09:27

Looking at it on my phone I suspect you have a missing space in the second line, it should read
"when item MyTemperatureSensor changed or item WantedTemperature changed then"

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#18 Post by shenery » 11 May 2017, 16:02

Its still not working. Here are my items rules and sitemap.
Attachments
Screenshot_20170511-145957.png
Screenshot_20170511-145957.png (191.98 KiB) Viewed 19258 times
Screenshot_20170511-150007.png
Screenshot_20170511-150007.png (92.58 KiB) Viewed 19258 times
Screenshot_20170511-150128.png
Screenshot_20170511-150128.png (111.45 KiB) Viewed 19258 times

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#19 Post by sheppy » 12 May 2017, 05:46

OK, lets see what is working.
Change your rules file to read

"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end

rule "test what is working"
when Item MyTemperatureSensorChanged or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
var MT = MyTemperatureSensor.state as Number
logInfo("Testing", "Wanted Temperature is " +WT
logInfo("Testing". "Sensed Temperature is " +MT
}
end

Now open up openhab.log - if you have Raspbian Jessie and an apt-get installation it is found in /var/log/openhab2 and can be seen live by typing

tail -f /var/log/openhab2/openhab.log for other operating systems and installations please see the openhab documentation

whenever the temperature changes or when you change the requested temperature you should see 2 log entries, the first with the set temperature, and the second with the sensed temperature. If any of these aren't the values you expect then you need to check your items file, and also for the sensed temperature you need to check the device running ESPEasy

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#20 Post by shenery » 12 May 2017, 09:15

Ok I've checked the log and it is only giving me wanted temperature when I click + or -I don't get any sensed temperature.

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#21 Post by sheppy » 12 May 2017, 09:32

Sounds like a ESPeasy or mqtt configuration problem, I'm unable to get to my PC for a day or so now, I'd recommend checking those things. When it's working you should see a valid reading in your sitemap that changes if you warm the sensor by warming it with your hand

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#22 Post by shenery » 12 May 2017, 22:37

Ok here's where I'm at.
I have openhab log working and I can now see sensed temperature
I can see wanted temperate
I can switch my heating switch on and off manually but not with altering the setpoint in the sitemap.
In the log with original rules you sent when I change set point I get wanted temperature changed but I don't see a command for on or off to the switch.
I have attached some screenshots.

Kind regards
Steven
Attachments
Screenshot_20170512-212455.png
Screenshot_20170512-212455.png (198.1 KiB) Viewed 19686 times
Screenshot_20170512-212609.png
Screenshot_20170512-212609.png (267.78 KiB) Viewed 19686 times
Screenshot_20170512-212829.png
Screenshot_20170512-212829.png (158.99 KiB) Viewed 19686 times

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#23 Post by shenery » 12 May 2017, 22:39

And here's one of me switching the heating on manually.
Attachments
Screenshot_20170512-213837.png
Screenshot_20170512-213837.png (168.89 KiB) Viewed 19685 times

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#24 Post by sheppy » 13 May 2017, 00:10

The purple writing in the screenshot suggests there is a problem with your rules file, and looking at my original rules there was a couple of missing close brackets. Usually I use smarthome designer from the openhab downloads site for my editing, whilst its not perfect, it catches most of these. I'd strongly recommend it for someone new to OpenHAB.
Now we have valid values, change the rules to read this, use copy and delete what is already there. If you get the purple cannot be parsed correctly rule there usually is a typo somewhere. Once it is working add // before each logging statement to stop it filling the logs

"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end

rule "test what is working"
when Item MyTemperatureSensor Changed or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
var MT = MyTemperatureSensor.state as Number
logInfo("Testing", "Wanted Temperature is " +WT)
logInfo("Testing", "Sensed Temperature is " +MT)
if (MT > WT) { sendCommand(Heater, OFF) }
if (MT + 0.1 < WT) {sendCommand(Heater, ON) }
}
end

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#25 Post by shenery » 13 May 2017, 14:44

I tried that and got the same error. I have eclipse installed but haven't really delved that deep in to it yet. Had a look last night and I can see all my files but not sure how to check syntax and stuff like that.
Also what do you mean with adding // before log entries?

Kind regards
Steven

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#26 Post by shenery » 14 May 2017, 12:37

Not even getting a decent log reading now. Don't know what I've done wrong. When I do log:tail I get endless readings and they go that fast I can hardly read them.
Attachments
Screenshot_20170514-105023.png
Screenshot_20170514-105023.png (222.04 KiB) Viewed 19641 times

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#27 Post by shenery » 14 May 2017, 21:16

I managed to get it working at last! :-) worked out how to find errors with eclipse smart home and turns out I had " in the wrong place. It was to the left of the. "Rule instead of rule " regulate temperature.
Thanks for all your help sheppy. I now have a working WiFi thermostat.

Kind regards
Steven

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#28 Post by sheppy » 15 May 2017, 22:35

Well done! Using the designer is a good idea as a small typo can waste much time when you are new to Openhab. It is a great system once you master it and https://community.openhab.org is a great place to search if you have a problem. ESPEasy also works very well with it

shenery
Normal user
Posts: 18
Joined: 06 May 2017, 10:27

Re: Ds18b20 temp and relay control via openhab

#29 Post by shenery » 16 May 2017, 10:35

Yeah. I'll be using eclipse a lot more, now that I know how to use it. Was pulling my hair out a bit but go there in the end. Was a good learning exercise.

Thanks again
Stevenn

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: Ds18b20 temp and relay control via openhab

#30 Post by sheppy » 18 May 2017, 00:34

One other thing I'd recommend is working out how you see the system ending up in future and then planning your MQTT topic tree so it makes sense going forward. For example you could have

Security/ containing the status of doors and windows
Heating/ or
Climate/ for your heater items or maybe extra sub topics make sense such as

Climate/LivingRoom/
Climate/MainBedroom/
Electricity/

Home automation systems have a habit of growing and what seems over complicated now may work out better in future when you are trying to debug an obscure fault.

When debugging you can use a program such as mqtt.fx subscribe to all messages with a simple "#" or subscribe to sub topics such as "Climate/#" or even in the above example "Climate/LivingRoom/#"

The first "/" in the topic tree isn't needed btw so your topic "/StevensLamp/gpio/12" could be simplified to "StevensLamp/gpio/12" as long as both OpenHAB and ESPEasy are changed

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Ds18b20 temp and relay control via openhab

#31 Post by waspie » 21 May 2017, 03:13

I have a whole bunch of stuff done on this topic I could help you with if I had my laptop up. I'm using many esp and motorized vents to regulate temperature like zoning in every room. I use openhab as well Image

The vent can be open closed or set for heat/cool. In heat or cool it opens or closes as temperature goes up or down depending on how you want it. Then, the use ac and use furnace switches affect a variable. If enough rooms want ac or heat there's another esp that'll turn on the hvav separate of the nest



Also, the readings of the Dallas are awesome, they vary very little. I used to use analog sensors and averaged them over 3 minutes using readings every 10 seconds. With the Dallas I have it send a reading every 3 minutes using a separate esp that's in deep sleep and battery powered away from the vent. The Dallas sensors are rock solid

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Ds18b20 temp and relay control via openhab

#32 Post by waspie » 22 May 2017, 17:53

HEre are the relevant portions if you want. Any questions, just ask.

nursery items

Code: Select all

Number	Nursery_Temperature 		"Nursery Temp	   [%.1f °F]" <temperature>	{mqtt="<[oh2:/NurserySensor/Nursery_Temp/NUR_TEMP:state:default]" }
Number	Nursery_Volts	 			"Nursery Volts	   [%.2f V]" <electric>	{mqtt="<[oh2:/NurserySensor/Nursery_Volt/NUR_VOLT:state:default]" }
Number	VT_Vent_Setpoint_Nursery 	"Nursery Setpoint [%.1f °F]"    <degreesf>
Number	VT_Vent_Mode_Nursery     	"Nursery Vent Control"          <heating>
Switch	FF_Nursery_Vent           	"Nursery Vents"         <fire>          {http=">[OFF:POST:http://192.168.1.151/control?cmd=event,closevent] >[ON:POST:http://192.168.1.151/control?cmd=event,openvent]"}
Number	AVG_Nursery		    		"Nursery Average Temp [%.1f °F]"	<degreesf>
Switch	FF_Nursery_Vents			"Nursery Vents"			<fan>
Number	VT_Nursery_Keepwarm			"Nursery Call Heat"		<fire>
Number	VT_Nursery_Keepcool			"Nursery call cool"		<fan>
Number	NurseryNeedHeat				"Nursery Heat Request"	<fire>

nursery rules (the use furnace / use ac stuff isn't done yet. that's why at least one section is missing. )

Code: Select all

rule "Nursery OnOff"
when
    Item VT_Vent_Mode_Nursery changed
then
    // 0="Off", 1="On", 2="Auto"
    if (VT_Vent_Mode_Nursery.state == 0) {
        // heater off
        FF_Nursery_Vents.sendCommand(OFF)
    } else if (VT_Vent_Mode_Nursery.state == 1) {
        // heater on
        FF_Nursery_Vents.sendCommand(ON)
        }
        else{
        FF_Nursery_Vents.sendCommand(ON)
        }
end

rule "Nursery Vents Status"
when
    Item VT_Vent_Mode_Nursery changed or
    Item VT_Vent_Setpoint_Nursery changed or
    Item Nursery_Temperature changed
then
	if (VT_Vent_Mode_Nursery.state == 2) {
		var Number setpointN = VT_Vent_Setpoint_Nursery.state as DecimalType
		var Number turnOnTempN = setpointN - 0.5
		var Number turnOffTempN = setpointN + 0.5
		var Number tempN = Nursery_Temperature.state as DecimalType
			if (tempN <= turnOnTempN) {
				FF_Nursery_Vents.sendCommand(ON)
			} else if (tempN >= turnOffTempN) {
				FF_Nursery_Vents.sendCommand(OFF)
				}			
	}
	if (VT_Vent_Mode_Nursery.state == 3) {
		var Number setpointN = VT_Vent_Setpoint_Nursery.state as DecimalType
		var Number turnOnTempN = setpointN + 0.5
		var Number turnOffTempN = setpointN - 1.5
		var Number tempN = Nursery_Temperature.state as DecimalType
			if (tempN >= turnOnTempN) {
				FF_Nursery_Vents.sendCommand(ON)
			} else if (tempN <= turnOffTempN) {
				FF_Nursery_Vents.sendCommand(OFF)
				}	
	}
end

rule "Nursery Vent Control"
when
	Item FF_Nursery_Vents changed
then
		if (FF_Nursery_Vents.state == ON){
			FF_Nursery_Vent.sendCommand(ON)
		} else if (FF_Nursery_Vents.state == OFF) {
			FF_Nursery_Vent.sendCommand(OFF)	
			}
end

rule "Nursery Use Furnace"
when 
	Item VT_Nursery_Keepwarm changed or
	Item Nursery_Temperature changed or
	Item VT_Vent_Mode_Nursery changed or
	Item VT_Vent_Setpoint_Nursery changed
then
	if (VT_Nursery_Keepwarm.state == 1 && VT_Vent_Mode_Nursery.state == 2) {
		var Number setpointN = VT_Vent_Setpoint_Nursery.state as DecimalType
		var Number turnOnTempN = setpointN - 0.5
		var Number turnOffTempN = setpointN + 0.5
		var Number tempN = Nursery_Temperature.state as DecimalType	
		if (tempN <= turnOnTempN) {
			postUpdate(NurseryNeedHeat,1)
		} else if (tempN >= turnOffTempN) {
			postUpdate(NurseryNeedHeat,0)
		} 
	}
	if (VT_Vent_Mode_Nursery.state == 0 || VT_Vent_Mode_Nursery.state == 1 || VT_Vent_Mode_Nursery.state == 3) {
		postUpdate(NurseryNeedHeat,0)
		}
	
end
sitemap

Code: Select all

	Text label="Nursery" icon="baby_1"{
        		Frame {
        		Switch item=VT_Vent_Mode_Nursery label="Vent Control" mappings=[0="Off", 1="On", 2="Heat", 3="Cool"]
				Setpoint item=VT_Vent_Setpoint_Nursery label="Target Temperature [%.1f °F]" minValue=65 maxValue=80 step=0.5 visibility=[VT_Vent_Mode_Nursery==2, VT_Vent_Mode_Nursery==3] icon="heating-60"
				Text item=FF_Nursery_Vent
				Text item=Nursery_Temperature
				Switch item=VT_Nursery_Keepwarm label="Use Furnace?"	mappings=[0="Off", 1="On"]
				Switch item=VT_Nursery_Keepcool label="User AC?"		mappings=[0="Off", 1="On"]
				Text item=Nursery_Volts icon="battery-90"
				Chart item=Nursery_Temperature period=4h refresh=300
				Chart item=Nursery_Volts period=D refresh=300
				}
        	    }



The reason i have a Vent and Vents item is one is virtual and i only want it to send a command to the actual ESP when the virtual *changes*
I don't want actuating the motor for no reason

Post Reply

Who is online

Users browsing this forum: No registered users and 59 guests