Temperature alarm

If you have a question or need help, this is the place to be.
Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Temperature alarm

Post by Lilak » Thu Jan 18, 2018 2:09 am

Hi, everybody!

I really need some help.

I have a thermometer in my freezer, and I want EG to to warn me if the temperature is below -20 degrees. The paylode I get from the temperature sensor is formated as -25.3|14, the first value is the temperature and the second is the humidity. I only want to use the temperature value.

For now I have got EG to start notepad when the temperature and humidity is -25.3|14.

I need help to get EG to ignore the humidity value, and make an event if the temperature is below a specific value.

Below you can see the macros i have now.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1710">
    <Macro Name="&lt;unnamed macro&gt;" Expanded="True">
        <Event Name="TellStickDuo.mandolyn.temperaturehumidity.21.Temperature.Humidity" />
        <Action>
            EventGhost.TriggerEvent(u'{(eg.event.payload)}', 0.0)
        </Action>
    </Macro>
</EventGhost>

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1710">
    <Macro Name="&lt;unnamed macro&gt;" Expanded="True">
        <Event Name="Main.-25.3|14" />
        <Action>
            System.Execute(u'notepad.exe', u'', 0, False, 2, u'', False, False, u'', False, False, False, False)
        </Action>
    </Macro>
</EventGhost>
Please ask if you need more information.

Thank you!

Best regards

Jonas

cvben
Posts: 38
Joined: Wed Jun 07, 2017 8:30 pm

Re: Temperature alarm

Post by cvben » Thu Jan 18, 2018 4:10 am

First I'd recommend updating to at least the latest version, though I do recommend the release candidate.

next try this:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4">
    <Macro Name="Python Script" XML_Guid="{54968E9B-05A3-4720-B9E6-62F70901B952}">
        <Event Name="TellStickDuo.mandolyn.temperaturehumidity.21.Temperature.Humidity" XML_Guid="{FA1C9F6A-2FB7-4BEF-8345-845777728626}" />
        <Action XML_Guid="{80FD96E2-B2FE-4955-BF9A-D69D7F666CCB}">
            EventGhost.PythonScript(u'print(eg.event.payload)')
        </Action>
    </Macro>
</EventGhost>
If your version wont accept this, simply add a python print command to the original event "TellStickDuo.mandolyn.temperaturehumidity.21.Temperature.Humidity" that should give you information about what, if anything is inside it. Hopefully some dictionary values where temperature is given.

If so you can do some eval in the same python script

for instance:

the original event triggers, then python code

Code: Select all

if tempval <=-20:
	eg.TriggerEvent(alarm)
if it doesn't contain a temp value in a dictionary/list/object you could always do something like so in a python script:

Code: Select all

data_1 = eg.event.payload
data_2 = data_1.split('|')

if data_2[0] <= -20:
    eg.TriggerEvent(alarm)

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Temperature alarm

Post by Lilak » Thu Jan 18, 2018 5:37 am

Thank you!

I tried the lastest version, and I tried the RC. I can't use either one, because a couple of my plugins wouldn't work.

The code you gave me didn't work with my version.

Next, "simply add a python print command to the original event", how do I do that?

Best regards

Jonas

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Temperature alarm

Post by kgschlosser » Thu Jan 18, 2018 7:01 am

just click the event in the log and copy it (ctrl+c) or right click it and click on copy. then paste it here.



from your explanation you would need to have a script like the one that follows.

This is what you would paste into a python script action. and place it directly under the event in the macro. this is going to stop the macro from running and exit it if the condition is met. if it is not met then the macro will continue running. so any action you place after this script in the macro will continue to run.

@cvben you forgot to do a type conversion from str to float before you do the comparison :wink: Good work on the script.

Code: Select all

if float(eg.event.payload.split('|')[0]) > -20:
    eg.StopMacro()
    eg.Exit()
But if you are using this in the Freezer you would want an event if the temperature gets to warm yes???

and if that is the case.

Code: Select all

if float(eg.event.payload.split('|')[0]) <= -20:
    eg.StopMacro()
    eg.Exit()
on another note. you mentioned that you are not able to run the newest version of EG does to plugins not functioning. would you be so kind as to tell me which plugins are not functioning. (if we don't know it's broke we don't know to fix it)
If you like the work I have been doing then feel free to Image

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Temperature alarm

Post by Lilak » Thu Jan 18, 2018 8:18 am

@kgschlosser

Thank you very much!

Works perfect, now I get a warning to my cellphone when the temperature rises ABOVE (thank you for noticing my mistake) -18 degrees C.

Of cource I will let you know the non working plugins. I will reinstall the RC. What information do you want from me?

Best regards

Jonas

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Temperature alarm

Post by Lilak » Thu Jan 18, 2018 8:43 am

@kgschlosser

Here's my problems with RC.

Plugin: Switch King
09:23:54 Starting Switchking V0.1.0
09:23:54 Failed to reach the Switch King server. Check Hostname and Port
09:23:54 Reason: Unauthorized

Plugin: Global Cache (This plugin works, but I get this in the log)
09:23:54 C:\Program Files (x86)\EventGhost\plugins\globalcache\__init__.py:545: DeprecationWarning: UdpServer.setsockopt is deprecated. Use UdpServer.socket.setsockopt instead.
09:23:54 self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

Best regards

Jonas

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Temperature alarm

Post by kgschlosser » Thu Jan 18, 2018 9:35 am

ok the second is a depreciation warning and is very easy to overcome.

The first on the other hand i have to take a look at and see if there is a way to get a full error from it. but I am thinking that it could possibly have something to do with SSL.
If you like the work I have been doing then feel free to Image

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Temperature alarm

Post by Lilak » Thu Jan 18, 2018 9:46 am

If you want me to test something, just send PM.

Best regards

Jonas
Last edited by Lilak on Thu Jan 18, 2018 11:05 am, edited 1 time in total.

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Temperature alarm

Post by kgschlosser » Thu Jan 18, 2018 10:23 am

attached is an updated version of the global cache plugin. It should fix the issue.

If you would be so kind as to give me a link to where the plugin is located so I can post a fixed version on there as well.

Not a good idea posting your e-mail on an open forum. you are going to end up getting all kinds of spam e-mail
Attachments
GlobalCache-0.1.1.egplugin
(25.2 KiB) Downloaded 71 times
If you like the work I have been doing then feel free to Image

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Temperature alarm

Post by Lilak » Thu Jan 18, 2018 11:04 am

I think I got it from http://www.eventghost.rocks/forum/db/pl ... bal_cache/

Thanks for the reminder about email.

Best regards

Jonas

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Temperature alarm

Post by kgschlosser » Thu Jan 18, 2018 11:04 am

give this version of Switchking a try. i converted it to use the requests library.
Attachments
Switchking-0.1.1.egplugin
(18.61 KiB) Downloaded 68 times
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Temperature alarm

Post by kgschlosser » Thu Jan 18, 2018 11:05 am

I see you found our work in progress plugin repository. EventGhost.rocks is a test site.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Temperature alarm

Post by kgschlosser » Thu Jan 18, 2018 11:07 am

let me know how those work out for ya.
If you like the work I have been doing then feel free to Image

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Temperature alarm

Post by Lilak » Fri Jan 19, 2018 4:17 am

@kgschlosser

globalcache plugin dosn't work

get this in the log: 05:11:22 Error: Global Cache, : 1:1 - Invalid frequency value.

Lilak
Posts: 36
Joined: Fri Dec 28, 2012 9:06 am
Location: Sweden

Re: Temperature alarm

Post by Lilak » Fri Jan 19, 2018 4:46 am

@kgschlosser

A clean install of EG RC, SwitchKing plugin doesn't work, get this in log


05:42:03 Plugin: Switch King
05:42:03 Starting Switchking V0.1.1
05:42:03 Error starting plugin: Switch King
05:42:03 Traceback (most recent call last) (0.5.0-rc4):
05:42:03 File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 192, in Start
05:42:03 self.instance.__start__(*self.args)
05:42:03 File "C:\Program Files (x86)\EventGhost\plugins\Switchking\__init__.py", line 326, in __start__
05:42:03 self.sk.connect('',"RESTDevice")
05:42:03 File "C:\Program Files (x86)\EventGhost\plugins\Switchking\__init__.py", line 142, in connect
05:42:03 response = requests.get(self.url + URL, headers=self.headers)
05:42:03 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\api.py", line 71, in get
05:42:03 return request('get', url, params=params, **kwargs)
05:42:03 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\api.py", line 57, in request
05:42:03 return session.request(method=method, url=url, **kwargs)
05:42:03 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\sessions.py", line 475, in request
05:42:03 resp = self.send(prep, **send_kwargs)
05:42:03 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\sessions.py", line 585, in send
05:42:03 r = adapter.send(request, **kwargs)
05:42:03 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\adapters.py", line 403, in send
05:42:03 timeout=timeout
05:42:03 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\packages\urllib3\connectionpool.py", line 578, in urlopen
05:42:03 chunked=chunked)
05:42:03 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\packages\urllib3\connectionpool.py", line 362, in _make_request
05:42:03 conn.request(method, url, **httplib_request_kw)
05:42:03 File "httplib.pyc", line 1057, in request
05:42:03 File "httplib.pyc", line 1096, in _send_request
05:42:03 File "httplib.pyc", line 1035, in putheader
05:42:03 ValueError: Invalid header value 'Basic bGlsYWs6MTM2NQ==\n'

Post Reply