Would it be safe to use EG as a multi-room thermostat?

If you have a question or need help, this is the place to be.
Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Sat Aug 25, 2012 8:37 pm

I have a cabin, and in the winter it gets a bit cold here in Norway. This is not in the worst part of the country, it's very far south and close to the sea, so we're not talking about 20 below freezing point most of the winter. It can get that cold every once in a while, but normally it's between a few degress above and five to ten below. This fall I will get full convenience package, with WC, shower, warm and cold water, dish washer, everything. They really don't like ice in the water works very much. So my plan was this: I already have wall heaters in all the rooms that are controlled with ARC (Nexa type 3500 watt switches called Sunmatic, reliable enough to never give me any problems while switching them on and off, and the distance to the RFXtrx433 is within 10 meters, so range is no problem) which I used last winter to have the cabin warm when we got there, and I have temperature probes in all rooms. It is possible to buy "frost guardians", or what ever they are called in English. That's a kind of a heater that keeps the temperature above freezing point at all times. But they are small, they can't be hung on the wall, and I would need them in all rooms. And besides I would really like to do this a bit more elegant/fancy. Since I already have all this equipment, and since the cabin is on the web 24/7 with a real broadband connection that I use from home to check in on the cabin every morning (camera, temperatures, humidity, the status of the UPC), I was wondering if I could use the ovens that are there as the frost guardians. I think it would go something like this:

Every so often (maybe every hour, so the switches and ovens aren't damaged by to much on/off) the temperature of all the rooms would be checked by some script. If it was below 3 C it would turn on the heater until the next hourly cycle, and if it then was above 4 C it would turn off the heater until the next cycle. I would also like to have a warning sent to me by mail if the temperature got down to 2 degrees. If that happens I can call my father or one of my two brothers. They all live within 15 minutes from the cabin. Would this be reliable enough, providing that I check up on it every day?

I have to admit that I have problems coding myself out of a brown paper bag, so I would need help on this. But I'm thinking that it can't be so original that nobody else has thought about it. So if this is reliable enough, has anybody has tried something similar and can share code with me that can be modified for my use?

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Would it be safe to use EG as a multi-room thermostat?

Post by krambriw » Sun Aug 26, 2012 6:07 am

I think this is feasible.

- try to keep the needed stuff in the cabin as simple as possible, i.e. keep the computer running EG at your regular home and try to setup a link to the RFXtrx via ip (using a USB to Ethernet server) if possible via a VPN

- dedicate a PC (like an old laptop, eventually you change the HDD to a SSD like I did to make it fast and quiet) for the cabin automation and only install the needed. To access it when you are not at home you could use Teamviewer.

- think about your use cases and identify the needed EG plugins that are already available and configure them with the basic data needed.

- monitoring temperature levels and creating actions if below or above is easy and reliable with python scripts (I have some scripts monitoring both of my freezers temp. If it is higher than -12 during a certain time period, EG informs me via mail and Growl/Prowl)

- be prepared that you have to start to understand python from the examples that will be discussed once you start off, do not expect that someone will give you a ready made solution. You could however expect help with scripts etc if you show real interest and commit yourself to do as much as you can yourself.

Best regards, Walter

Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Sun Aug 26, 2012 7:06 am

Thanks for the tips! Actually the pure PC part is no problem. I have a Windows Server 2003 running 24/7, and on that I have a virtual machine with EG. This hasn't skipped a beat since I installed it last winter, so I'm not afraid of that. And the server at home is an exact twin of it, bith have i7 CPUs, SSDs and lots and lots of hard drive space, with 5-6 running virutal machines. So the server itself is only the "skeleton" that it runs on. The server also has an OpenVPN link to my home server, and I use Log me In, RealVNC or Remote Administrator to control it. So that part of it is no problem.

That freezer script you're talking about could be exactly what I'm looking for, changing what happens and at what temperature wouldn't be above my very meager coding skills, I think. I could even use that at my freezer at home (which already has its own Viking temperature sensor). Would you care to share that? :)

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Would it be safe to use EG as a multi-room thermostat?

Post by krambriw » Sun Aug 26, 2012 1:10 pm

Here is a simple script that monitors the temperature and compares it with a threshold level. Put it in a new macro together with the RFXtrx event you want to monitor.

A typical event from RFXtrx for a Temp/Hum sensor looks like this:

Code: Select all

#13:24:10   RFXtrx.Type: THGN122/123, THGN132, THGR122/228/238/268 id: 8194 ' temperature: +17.6 deg C humidity: 76 %RH status: wet signal: 6 battery: 9'
The script below extracts the temperature and generates a new event that can be used to trigger another macro that turns heating on in that area. To turn off heating, you can have a similar script but checking when temperature is below the threshold instead.

Code: Select all

newEvent = str(eg.event.suffix)
newPayload = eg.event.payload

name = 'My freezer' #Insert the name of the monitored area
id = 17920 #The id of the sensor
alarm_level = 3.0 #threshold level

if newEvent.split(':')[2].find(str(id)) > 0:
    temp = newPayload.split(' ')[1]
    if float(temp) < alarm_level:
        eg.TriggerEvent(
            name
            +"|"
            +'Low Temperature'
            +"|"
            +str(id)
            , payload = (
                str(round(float(temp), 1)),
                str(alarm_level)
            )
        )

Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Sun Aug 26, 2012 2:59 pm

Thanks a lot! I'll play around with that when I get the time (totally crazy schedule on the job from yesterday and until next weekend). I'll let you know what I manage to do. :)

Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Sun Sep 09, 2012 6:04 pm

Well, I finally got to it. I must admit that Python is very difficult for me. I do a tiny bit of LUA, but this is a completely different animal...

I have modified the code to this (to get the correct sensor):

Code: Select all

newEvent = str(eg.event.suffix)
newPayload = eg.event.payload

name = 'Fryseren' #For this test I'm using the deep free, Fryseren in Norwegian
id = 17152 #The correct id of the sensor
alarm_level = -22.6 #threshold level set, and that's the level that the sensor gave back on this run, but the same error comes anyway

if newEvent.split(':')[2].find(str(id)) > 0:
    temp = newPayload.split(' ')[1]
    if float(temp) < alarm_level:
        eg.TriggerEvent(
            name
            +"|"
            +'For varmt'#"Too warm" in Norwegian, this triggers a simple action for now: Opening Notepad
            +"|"
            +str(id)
            , payload = (
                str(round(float(temp), 1)),
                str(alarm_level)
            )
        )
And that gives me this error:

Code: Select all

20:01:13            Traceback (most recent call last):
20:01:13              Python script "10", line 10, in <module>
20:01:13                if float(temp) < alarm_level:
20:01:13            ValueError: invalid literal for float(): temperature:
What have I done wrong here? I know it's me...

Another thing: This runs the action every time the temp sensor comes back. Can you please tell me what's needed to make it only check every hour, like I asked for in the first post? Every 20 seconds, or what the Viking sends, is too much on and off for an oven. It doesn't have time to get warm before it may be turned off again. :)

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Would it be safe to use EG as a multi-room thermostat?

Post by krambriw » Mon Sep 10, 2012 4:26 am

Please paste a copy of the event you get from the rfxtrx so I can check the format of it.

Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Mon Sep 10, 2012 6:27 am

Thanks! This is what it looks like:

Code: Select all

08:26:53   RFXtrx.Type: Viking 02811 id: 17152 ' temperature: -22.5 deg C signal: 5 battery: 9'

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Would it be safe to use EG as a multi-room thermostat?

Post by krambriw » Mon Sep 10, 2012 7:11 am

In your script, try to change

temp = newPayload.split(' ')[1]

to

temp = newPayload.split(' ')[2]


You have set the alarm level to -22.6

But you are having

if float(temp) < alarm_level

What do you want to monitor? If it gets colder or warmer?

If you want to monitor if it gets warmer in the freezer, you should have:

if float(temp) > alarm_level

Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Mon Sep 10, 2012 8:05 am

Thank you very much, got it! :) I made it into two different scripts, one that warns when it's too hot and one that warns if it's too cold. Both work now and do their test events (start notepad when it's too hot and explorer when it's too cold) without any problems. Only one thing missing now: The ability to decide how often that event should be fired. Is that easiest to do in the main monitoring script or is it possible to do it in the action or event item, so that even if the the event comes it doesn't fire the action more often than I set it to? I hope you understand what I mean, I see that I'm not expressing myself very clearly... :lol:

Edit: Another thing is that it is nice to get a warning when the freezer is too hot, but if I get the warning every time the info from the sensor comes in, that's a bit much. :) I'm sure some limitation like that has been done often before, right?

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Would it be safe to use EG as a multi-room thermostat?

Post by krambriw » Mon Sep 10, 2012 8:47 am

You can have a look at this script I made for controlling an AC unit. It has hysteres as well and triggers only only when the levels are reached. The trick is the "status" variable that is used to check if triggering the event shall happen or not.
You easily adopt those changes to your freezer script.

Best regards, Walter

Code: Select all

#AC Unit Control
newEvent = str(eg.event.suffix)
newPayload = eg.event.payload
name = 'My AC Unit'
id = 17920
high_level = 25.0
low_level = 22.0

try:
    status
except NameError:
    status = None

if newEvent.split(':')[2].find(str(id)) > 0:
    temp = newPayload.split(' ')[2]

    if(
        float(temp) > high_level
        and (
                status == 'OFF'
                or
                status == None
            )
    ):
        eg.TriggerEvent(
            name
            +"|"
            +'High Temp Level reached'
            +"|"
            +str(id)
        )
        status = 'ON'
           
    if(
        float(temp) < low_level
        and (
                status == 'ON'
                or
                status == None
            )
    ):
        eg.TriggerEvent(
            name
            +"|"
            +'Low Temp Level reached'
            +"|"
            +str(id)
        )
        status = 'OFF'
           



Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Mon Sep 10, 2012 8:59 am

Thanks a lot again! But easily? :mrgreen: I think we're talking of The Dilbert Principle here now... I have reached my level of incompetency. But if I understand that correct, this sets a variable telling the script that the unit is already on. Is that correct? In that case you may have misunderstood me. I don't need that, I need something that I can set to a number of minutes that I define myself, and then it reacts to the input from the sensor. I guess I could use an EventGhost action to disables the actions and at the same time starts a timer that enables the action the number of minutes I need later, but it seems very untidy and unnecessary complicated. And complication always means that more stuff that can go wrong. Still, if that's the only way to do that, I will use it. But if you have a bit of code that can do the minute thing instead, that would be much appreciated.

Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Tue Sep 11, 2012 8:24 pm

I'll have to use the dirty version with timers, then? :)

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Would it be safe to use EG as a multi-room thermostat?

Post by krambriw » Wed Sep 12, 2012 8:32 am

You can try this script, just modify the data according to your needs.

BR Walter

Code: Select all

try:
    dummy
except NameError:
    dummy = 0
    eg.globals.status = None


def allowEvent():
    eg.globals.status = 'ON'


#08:26:53   RFXtrx.Type: Viking 02811 id: 17152 ' temperature: -22.5 deg C signal: 5 battery: 9'
#newEvent = 'Type: Viking 02811 id: 17152'
#newPayload = ' temperature: -22.5 deg C signal: 5 battery: 9'
newEvent = str(eg.event.suffix)
newPayload = eg.event.payload
name = 'Fryseren' #For this test I'm using the deep free, Fryseren in Norwegian
id = 17152 #The correct id of the sensor
alarm_level = -21.6 #threshold level set, and that's the level that the sensor gave back on this run, but the same error comes anyway
wait = 5.0

if newEvent.split(':')[2].find(str(id)) > 0:
    temp = newPayload.split(' ')[2]
    if(
        float(temp) < alarm_level
        and (
                eg.globals.status == 'ON'
                or
                eg.globals.status == None
            )
    ):
        eg.TriggerEvent(
            name
            +"|"
            +'For varmt'#"Too warm" in Norwegian, this triggers a simple action for now: Opening Notepad
            +"|"
            +str(id)
            , payload = (
                str(round(float(temp), 1)),
                str(alarm_level)
            )
        )
        eg.scheduler.AddTask(wait, allowEvent)
        eg.globals.status = 'OFF'


Pallantir
Posts: 41
Joined: Mon May 14, 2012 6:41 pm

Re: Would it be safe to use EG as a multi-room thermostat?

Post by Pallantir » Wed Sep 12, 2012 8:36 am

Thank you very, very much! I'll be looking at that this weekend. :D

Post Reply