Hi their,
I am using OpenHab1 for a while now and I am very happy… But because I want to connect Alexa - I am just traying to set up my old raspberrypi2b with openhab2 to migrate later to my raspberrypi3 hardware. I am using openhabian and most of the items and sitemaps are already up and running.
But the “thinks” thing is killing me…
First of all my settings:
AM2302sensor.sh:
#!/bin/bash
INPUT22=$(/home/openhabian/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 22)
TEMP22=$(echo $INPUT22|cut -d " " -f1 | sed 's/[^0-9.]*//g')
HUM22=$(echo $INPUT22|cut -d " " -f2 | sed 's/[^0-9.]*//g')
INPUT4=$(/home/openhabian/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 4)
TEMP4=$(echo $INPUT4|cut -d " " -f1 | sed 's/[^0-9.]*//g')
HUM4=$(echo $INPUT4|cut -d " " -f2 | sed 's/[^0-9.]*//g')
ADDW=5.00
if [ "$1" = "HUM22" ]; then
echo $HUM22 $ADDW | awk '{print $1 + $2}'
fi
if [ "$1" = "TEMP22" ]; then
echo $TEMP22
fi
if [ "$1" = "HUM4" ]; then
echo $HUM4 $ADDW | awk '{print $1 + $2}'
fi
if [ "$1" = "TEMP4" ]; then
echo $TEMP4
fi
2017-06-23 14:58:54.043 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘22.6
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)’ for item ‘LUFT_Keller4’ to handler for channel ‘exec:command:gude:TEMP4’, because no thing with the UID ‘exec:command:gude’ could be found.
2017-06-23 15:00:19.726 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘22.5
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
/usr/lib/python2.7/dist-packages/pkg_resources.py:1049: UserWarning: /var/lib/openhab2/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)’ for item ‘LUFT_Keller4’ to handler for channel ‘exec:command:gude:TEMP4’, because no thing with the UID ‘exec:command:gude’ could be found.
The log shows that the temperature can be determined. BUT:
What do I have to change so that the value can be passed?
What exactly do I have to do against the Security Warning - I’m not a linux expert?
How can I set the Think to pass TEMP4 with the item? (like: channel=“exec:command:dht22:TEMP4”)
Your TEMP_Keller4 Item has an incomplete Channel ID. I think it needs to end in “:output” like your Luftf one does.
Change the permissions on /var/lib/openhab2/.python-eggs to remove write permissions from group and others
sudo chmod go-w /var/lib/openhab2/.python-eggs
I don’t know if I fully understand the question. But if you are asking for a way to have “TEMP4” to be passed to the script as a command line argument you need to create a String Item linked to the input channel. Whatever that String Item is set to gets appended to the command as a command line argument.
If you want the string “TEMP4” to be part of the value that TEMP_Keller4 receives you need to have your script echo that as part of its output.
channel="exec:command:dht22:TEMP54 is not a valid channel ID and is meaningless in OH.
If the only thing the script returns of a valid number with no white space around it, just change your String Item to a Number Item. Otherwise you need a transform or rule to convert it to something that can be parsed into a number.
rule "test123"
when
Time cron "0/10 * * * * ?"
then
var Number vtemp_keller4 = (TEMP_Keller4.state as DecimalType).intValue
logInfo("Test", "Bla: " + TEMP_Keller4.state + " Blub: " + vtemp_keller4)
end
2017-06-27 17:28:40.009 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule test123: org.eclipse.smarthome.core.library.types.DecimalType
2017-06-27 17:28:50.009 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule test123: org.eclipse.smarthome.core.library.types.DecimalType
2017-06-27 17:29:00.014 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule test123: org.eclipse.smarthome.core.library.types.DecimalType
I have a workaround but without the decimal places:
rule "UpdateToNumber"
when
Item TEMP_Keller4_string received update or
Item LUFT_Keller4_string received update
then
var Number Temp
var Number Luft
Temp=Integer::parseInt(String::format("%s",TEMP_Keller4_string.state).substring(0,2))
TEMP_Keller4.postUpdate(Temp)
Luft=Integer::parseInt(String::format("%s",LUFT_Keller4_string.state).substring(0,2))
LUFT_Keller4.postUpdate(Luft)
logInfo("Test", "Bla-: " + TEMP_Keller4 + " Blub-: " + LUFT_Keller4)
end
Sorry now I understand But I have treied that already. It is not working.
2017-06-27 19:41:47.528 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type REGEX
2017-06-27 19:41:47.531 [WARN ] [hab.binding.exec.handler.ExecHandler] - Couldn't transform response because transformationService of type 'REGEX' is unavailable
I’m sorry if I come off a little angry, but I’m becoming frustraited with this and a couple of other threads where I have to play 20 questions for every new reply and half of my replies and links are not being read.
At this point I have no idea what you have done, what you have working and what is not working. I’m through trying to figure problems out with only “its broken” to go on.
Here is how I would do it. If it doesn’t work post here (and for any new problem you have) at a minimum:
relevant Things
relevant Items
relevant Rules
relevant sitemap entries
relevant logs, especially if there are errors
#!/bin/bash
INPUT22=$(/home/openhabian/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 22)
TEMP22=$(echo $INPUT22|cut -d " " -f1 | sed 's/[^0-9.]*//g')
HUM22=$(echo $INPUT22|cut -d " " -f2 | sed 's/[^0-9.]*//g')
INPUT4=$(/home/openhabian/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 4)
TEMP4=$(echo $INPUT4|cut -d " " -f1 | sed 's/[^0-9.]*//g')
HUM4=$(echo $INPUT4|cut -d " " -f2 | sed 's/[^0-9.]*//g')
ADDW=5.00
if [ "$1" = "HUM22" ]; then
echo $HUM22 $ADDW | awk '{print $1 + $2}'
fi
if [ "$1" = "TEMP22" ]; then
echo $TEMP22
fi
if [ "$1" = "HUM4" ]; then
echo $HUM4 $ADDW | awk '{print $1 + $2}'
fi
if [ "$1" = "TEMP4" ]; then
echo $TEMP4
fi
I’m assuming that this string returns a parsable number with no stray characters and no leading or trailing white space.
Number TEMP_Keller4 "Temp 4 Keller [%.1f]" <temperature> (gTemp) {channel="exec:command:dht22temp4:output"}
Number LUFT_Keller4 "Luftf. 4 Keller [%.1f]" <temperature> (gTemp) {channel="exec:command:dht22hum4:output"}
Rule:
rule "test123"
when
Item TEMP_Keller4 received update
then
logInfo("Test", "Bla: " + TEMP_Keller4.state.toString)
var tempPlusFive = (TEMP_Keller4.state as Number) + 5
logInfo("Test", "Plus 5: + tempPlusFive)
end
Sitemap:
Text item=TEMP_Keller4
If for some reason the script is not returning a value that can be parsed into a String (e.g. contains white space) see this posting for how to trim out the whitespace using a JavaScript transform.
Are you for real???
I am hoping you are not!
Sorry for the possible frustration I may cause!
openHAB is for the ones that understand the basics of logic, the rest are details (sorry to be rude again!)
Then @rlkoshak said:[quote=“rlkoshak, post:2, topic:30449, full:true”]
the proper word is “Thing”, not “Think”.
Your TEMP_Keller4 Item has an incomplete Channel ID. I think it needs to end in “:output” like your Luftf one does.
Change the permissions on /var/lib/openhab2/.python-eggs to remove write permissions from group and others
sudo chmod go-w /var/lib/openhab2/.python-eggs
I don’t know if I fully understand the question. But if you are asking for a way to have “TEMP4” to be passed to the script as a command line argument you need to create a String Item linked to the input channel. Whatever that String Item is set to gets appended to the command as a command line argument.
If you want the string “TEMP4” to be part of the value that TEMP_Keller4 receives you need to have your script echo that as part of its output.
channel="exec:command:dht22:TEMP54 is not a valid channel ID and is meaningless in OH.
[/quote]
Then you said:[quote=“Quake3Arena, post:3, topic:30449”]
Thank you so much!
Then Rich said:[quote=“rlkoshak, post:4, topic:30449, full:true”]
If the only thing the script returns of a valid number with no white space around it, just change your String Item to a Number Item. Otherwise you need a transform or rule to convert it to something that can be parsed into a number.
[/quote]
Then you said:[quote=“Quake3Arena, post:5, topic:30449”]
I am to stupid
rule “test123”
when
Time cron “0/10 * * * * ?”
then
var Number vtemp_keller4 = (TEMP_Keller4.state as DecimalType).intValue
logInfo(“Test”, "Bla: " + TEMP_Keller4.state + " Blub: " + vtemp_keller4)
end
2017-06-27 17:28:40.009 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule test123: org.eclipse.smarthome.core.library.types.DecimalType
2017-06-27 17:28:50.009 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule test123: org.eclipse.smarthome.core.library.types.DecimalType
2017-06-27 17:29:00.014 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule test123: org.ecli
[/quote]
And then you said:[quote=“Quake3Arena, post:6, topic:30449, full:true”]
I have a workaround but without the decimal places:
rule “UpdateToNumber”
when
Item TEMP_Keller4_string received update or
Item LUFT_Keller4_string received update
then
var Number Temp
var Number Luft
Temp=Integer::parseInt(String::format(“%s”,TEMP_Keller4_string.state).substring(0,2))
TEMP_Keller4.postUpdate(Temp)
Luft=Integer::parseInt(String::format(“%s”,LUFT_Keller4_string.state).substring(0,2))
LUFT_Keller4.postUpdate(Luft)
Thats bad because I want to have the 21.7 as an exaple.
[/quote]
And then Rich said:[quote=“rlkoshak, post:7, topic:30449, full:true”]
You cannot just cast a String into a DecimalType. You must parse the String.
(TEMP_Keller4.state as DecimalType)
for a String Item is nonsensical. You must parse the String into a Number.
Like I said:
If the only thing the script returns of a valid number with no white space around it, just change your String Item to a Number Item.
[/quote]
And in your almighty wisdom, you asked:[quote=“Quake3Arena, post:8, topic:30449”]
Sorry but where in my test rule i have to enter it?
[/quote]
And Rich patiently answered:[quote=“rlkoshak, post:9, topic:30449”]
You don’t. I was showing you the part of your rule that is wrong.
I’ll say it once again, DEFINE YOUR ITEMS AS NUMBERS
Number TEMP_Keller4 “Temp 4 Keller [%s]” <temperature> (gTemp) {channel=“exec:command:dht22temp4:output”}
Number LUFT_Keller4 “Luftf. 4 Keller [%s]” <temperature> (gTemp) {channel=“exec:command:dht22hum4:output”}
[/quote]
And then you come back:[quote=“Quake3Arena, post:10, topic:30449”]
Sorry now I understand But I have treied that already. It is not working.
2017-06-27 19:41:47.528 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type REGEX
2017-06-27 19:41:47.531 [WARN ] [hab.binding.exec.handler.ExecHandler] - Couldn’t transform response
[/quote]
And Rich tries to keep his calm down:[quote=“rlkoshak, post:11, topic:30449, full:true”]
“Cannot get service reference for transformation service of type REGEX”
Probably means you don’t have the REGEX addon installed.
[/quote]
And then you finally try to not be proactive:[quote=“Quake3Arena, post:12, topic:30449, full:true”]
Thank you for this further note. But this only fixes another problem. I still get no values when I change the item to “number”.
[/quote]
And RIch as calm as he trie to be, loses his temper (absolutely justifiable in your case):[quote=“rlkoshak, post:13, topic:30449, full:true”]
I’m sorry if I come off a little angry, but I’m becoming frustraited with this and a couple of other threads where I have to play 20 questions for every new reply and half of my replies and links are not being read.
At this point I have no idea what you have done, what you have working and what is not working. I’m through trying to figure problems out with only “its broken” to go on.
Here is how I would do it. If it doesn’t work post here (and for any new problem you have) at a minimum:
relevant Things
relevant Items
relevant Rules
relevant sitemap entries
relevant logs, especially if there are errors
Number TEMP_Keller4 “Temp 4 Keller [%.1f]” <temperature> (gTemp) {channel=“exec:command:dht22temp4:output”}
Number LUFT_Keller4 “Luftf. 4 Keller [%.1f]” <temperature> (gTemp) {channel=“exec:command:dht22hum4:output”}
Rule:
rule “test123”
when
Item TEMP_Keller4 received update
then
logInfo(“Test”, "Bla: " + TEMP_Keller4.state.toString)
var tempPlusFive = (TEMP_Keller4.state as Number) + 5
logInfo("Test", "Plus 5: + tempPlusFive)
end
Sitemap:
Text item=TEMP_Keller4
If for some reason the script is not returning a value that can be parsed into a String (e.g. contains white space) see this posting for how to trim out the whitespace using a JavaScript transform.
[/quote]
And then you try again:[quote=“Quake3Arena, post:14, topic:30449, full:true”]
Again thank you so much for your help and sorry for making you frustraited.
But as I told you before. It is not possible to change the item to a “Number”:
Ok, in retrospect, some of my posts might be overpowered and I should have thought about it. Nevertheless, I try to understand the core statement: “Change the item from String to Number” and exactly that does not work.
Or is my English so bad that I understand everything here completely wrong?
I apologize seriously that I can not see my mistake here.
btw.:
Is that “only a number” or do you mean that the dot is not valid for the number-item? If that is the case I realy understand your frustation and my fail…
This is false. You have provided absolutely no information to indicate that it is impossible to use a Number Item. All you have said is “it doesn’t work” with no details. You post no logs with errors. You have yet to post exactly what it is your script actually returns (i.e. does it include spaces around the number? does it include units or something else like that)?
Are there any errors in the log?
In this posting and your later posting it is clear that the number should be parsable so, lets just assume that a Number cannot work with the output channel of the Exec 2.x binding.
In that case you have two options. Create another Number Item that gets updated every time the TEMP_Keller4_String Item gets updated:
rule "Convert String temp to Number"
when
Item TEMP_Keller4_String received update
then
TEMP_Keller4.postUpdate(TEMP_Keller4_String.state.toString)
end
or convert the String to a number wherever you want to use it in a rule:
rule "Some rule that does math on TEMP_Keller4"
when
Some trigger
then
// do some rule stuff
val tempVal = Float::parseFloat(TEMP_Keller4.state.toString)
val plusFive = tempVal + 5
// do other stuff
end
The source of my frustration is you do not provide enough details to really help you. I either have to drag details out of you by asking lots and lots of questions that should have been included as part of your posts or make wild guesses as to what you are trying to accomplish. Both take a lot of time and cause a lot of frustraition.
Instead of " I still get no values when I change the item to “number”." which could mean anything from your script is outputing something that cannot be parsed into a number to you messed something up, you could say:
"I tried to change the Item to a Number:
Number TEMP_Keller4 "Temp 4 Keller [%.1f]" <temperature> (gTemp) {channel="exec:command:dht22temp4:output"}
The sitemap still shows “-”.
I see these errors in the logs:
// logs showing errors
I changed the rule to be this:
// new rule with changes
when I run the script it returns this
// screenshot like you finally did
"
To have any hope of helping we need all of this information almost every step of the way. Otherwise it is like going to the doctor and saying “I hurt” and making him ask a million questions just to figure out where it hurts. Help us help you by providing as many details and help you can.