pimatic / pimatic

A home automation server and framework for the raspberry pi running on node.js
http://pimatic.org
GNU General Public License v2.0
596 stars 145 forks source link

Support for MAX! Thermostat #127

Closed georg90 closed 9 years ago

georg90 commented 10 years ago

Summary of the topic

(updated 25.09.14)


Hi it seems like there are no information available that somebody successfully has a thermostat running with pimatic?

I looked for a cheap solution to get one regular radiator to be controled via rules in pimatic. Something like "if it's 8am and a weekday and temperatur of device1 is < 20°C turn radiator on for 30min" etc. Also have a field where I can set the temperatur manually. And of course communicate with the thermostat, when I change it manually ;-)

I found the "homematic 105155" which seems to support all I want, but there are only stories available for FHEM etc. So I don't know if pimatic already supports devices like this?! Is there "plug and play" way to get a pimatic controled thermostat? So a device known to work with the raspberry pi and wireless connection + pilight + pimatic?

Sorry if this is the wrong place to ask.

Thanks, Georg

georg90 commented 10 years ago

Edit: I found a (for me) good combination working with FHEM.

(German - HowTo with FHEM) http://www.lexxi.at/2013/01/14/heizungssteuerung-mit-fhem-und-raspberry-pi/ (Fully equipt - ready to go) http://www.amazon.de/ELV-Funk-Heizk%C3%B6rperthermostat-Spar-Set-einen-Raum/dp/B0030U9GES/ref=pd_cp_ce_1 (assembly kit) http://www.elv.de/ventilantrieb-fht8v-2-arr-bausatz-inkl-batterien.html

So if you have some soldering skills you can have one radiator equipt with as little as 25€.

Any chance to port a basic config like this to pimatic? Or connect to FHEM?! (I prefer the neat looking interface of pimatic!)

I will order one and see if I can get something out of it. :)

sweetpi commented 10 years ago

The problem with the fhem solutions is that you additional need the (expensive and complicated) CUL Hardware from busware.

I don't like the style of the thermostats, too. I'm thinking about trying my luck with the MAX! products. It should be relativ easy to integrate them with the LAN Cube Gateway. At least other are doing it.

In an long time vision I'm planing to support these MAX! systems. But I can't say when and if I will have success.

georg90 commented 10 years ago

So you already own one? The Max! System was always quoted as expensive when I did my research..but since you only need the one LAN Cube, it's relativly easy + the thermostat itself it very inexpensive it might be the better solution. Also you can combine the wall interface & the automated solution.

I wonder why nobody else is interested in this?! Since pimatic aims to automate your home, heating would be one of the first things that comes in mind :)

sweetpi commented 10 years ago

No I'm not owning one yet. Still thought to find something better.

The cube is a little bit expensive but I think the starter kit has a good price value ratio and the additional components are relative cheap.

The biggest disadvantage is that the thermostats only send the tempersture on polling through the cube (http://www.fhemwiki.de/wiki/MAX#IST-Temperaturwerte)

georg90 commented 10 years ago

Max! System sounds good for a "big" solution..since I only want to control my living room (for now) I'm looking for a dirt cheap solution, enjoying some customizing ;-)

The general problem with 868mhz is the expense of the sender/receiver modul - as we already own a pi with a 433mhz receiver/sender, it would be easier to use this standard (I'm aware of the disadvantages, no feedback etc.) but this way (for now) I can save some money So I came along this: http://www.casacontrol.info Which is sending on 433mhz, and with some luck you can just use pilight with the raw command to get the content the station is sending to the thermostat?! Using this you could implement a very basic funktionality and using pimatic as of now + some rules to automate the process.

For me I only want to check the temperatur with my 1-wire sensor and have a rule which let's say turn up the heat at 8am-10am to 21°C and shut it down to 17°C from 10am to 8pm ... and so on. This should work, if you can catch the signal of the control station sending to the thermostat.

DIY it is..

koffienl commented 10 years ago

When you put an actuator to that one radiator in the living room, how do you plan to tell your heating system to fire up the power/flames?

georg90 commented 10 years ago

I'm living in an apartment building. In Germany we usually have a central heating system in the basement, which is producing heat for the whole building (also hot water). I don't have any control of this process. (don't want any :-P) So the only thing how you can control the heat is by turn the radiator on/off. So basicly anything I would need is a cheap wireless thermostat :)

koffienl commented 10 years ago

That make's it a lot easier ;) In The Netherlands I have have a similair system, it's called cityheating. My energyprovider gives me hot radiator water. I can control a electric valve to enable or disable flow of this hot water in the closed system. Since I only heat my kitchen and living room, I can control this main valve. All other radiators in the house are closed. For future I really would like something as the Max or CUL hardware on each radiator - but controlled from a Pi, based on several sensors. So basicly only a electronic actuator controllable with a Pi / RF

koffienl commented 10 years ago

OK, you got me triggered with these acuators ;) Conrad sells them under different names, and also available in the Netherlands. They work on 868 Mhz. Instead of reverse engineering these protocols (first receiving the wireless temp, later controlling the actuator), you could try to break open a RF and swap out as much as unusable hardware. All you need is to replce it with a PCB with a attiny and a RF receiver, so you can adopt the KaKu protocol in the attiny to control the actual actuator in the box. Voila : now you have a actuator that can be controlled with the KaKu protocol from pimatic/pilight :)

Just a brainfart ..

georg90 commented 10 years ago

Do you have link?

koffienl commented 10 years ago

http://www.conrad.nl/ce/nl/product/570056/FS20-Draadloze-stelaandrijving/?ref=category&rt=category&rb=1

betz0r commented 10 years ago

Has anybody any further information about http://www.elv.de/raumregler-fht-80b-arr-bausatz-inkl-batterien.html (base) and http://www.elv.de/ventilantrieb-fht8v-2-arr-bausatz-inkl-batterien.html (thermostat)? Which wireless protocol do they use? I guess i read somewhere its 433 but don't judge me if not. Maybe this is a cheap option?

I am also looking for a system to control at least 6 radiators.

sweetpi commented 10 years ago

Its most likely that I will build a plugin for the elv max! system. But I can't give a guarantee and don't know when I will find the time for it.

koffienl commented 10 years ago

What kind of apporach do you have for communicating with the Max! system? Are you going to communicate with the box, ore directly with the actuators?

sweetpi commented 10 years ago

I would use the cube, because I think thats the easies and most reliable solution.

Some links:

koffienl commented 10 years ago

.. but brings in a extra piece of hardware to buy, and adds an extra point of failure. But offcourse it is a lot of easier and documented :)

sweetpi commented 10 years ago

Thats unfortunately true. But don't know a other way (yet).

georg90 commented 10 years ago

I bought the MAX! System, it's working great, the cube is a huge benefit as it is cheaper than an CUL and simply "works".

I want to use pimatic (some day) to control the thermostats connected to the cube..so the first step is to get out of the golden cage and start using the cube without the java application (ELV)

I found this interesting: http://www.schrankmonster.de/2012/12/10/elv-max-cube-c-library-control-cube/ http://www.schrankmonster.de/2012/11/09/elv-max-cube-solar-log-500-state-reverse-engineering-h-a-c-s/ http://blog.hekkers.net/tag/elv-max/

etc. this guys did some work!

So I'll try to talk to the cube and get &send information for now.

Edit: I successfully queried the server with this script: http://www.mega-nas.de/max/readerscript.php Standard port is 62910

Let's see tmr if we can send something ;-)

georg90 commented 10 years ago

So I have found a basic webinterface with php: http://www.mega-nas.de/max/max.zip I modified the script a little bit to fit on my iPad..

I'm able to change the device status, temperatur, mode etc.

heating

This is working in php..so it shouldn't be too hard to get it working with pimatic & coffee script :)

georg90 commented 10 years ago

Update! I made my own update script (written in php for now) to update the temperature or switch mode. I realized everything with GET Parameters, so the script can be called from anywhere.

Now I want to implement this in pimatic..

Ideas:

I looked in the development guide, but find it very hard to find a point to start.. I need some new device types..they need to parse buttons, temperature and text..this differs very much from what pimatic is doing at the moment (on/off buttons, showing the temperature)

Can somebody provide some help? How can I create a plugin which creates a new object (where you can define a deviceNo and RoomID) and simply calls the php script with the parameters?

Any help is appreciated! Thanks :)

PS: If somebody is interested in the simple php script, I will upload it somewhere..

sweetpi commented 10 years ago

Now I want to implement this in pimatic..

Sound great :)

Having an object where the actual temperature is show with +/- button on each side to change the temperature directly

I assume that you mean Device in pimatic speech, when you write object?

I looked in the development guide, but find it very hard to find a point to start..

Where exactly do you get stuck?

I need some new device types..they need to parse buttons, temperature and text..this differs very much from what pimatic is doing at the moment (on/off buttons, showing the temperature)

Nor really from framework view it would be a new device with:

Attributes:

Actions:

and a custom template.

For the gui you then would need to define a template (new guide from yesterday :D) that displays the gui buttons and calls the actions.

How can I create a plugin which creates a new object (where you can define a deviceNo and RoomID) and simply calls the php script with the parameters?

deviceNo and roomId would be part of the device config.

georg90 commented 10 years ago

I assume that you mean Device in pimatic speech, when you write object?

Yes.

Where exactly do you get stuck?

I don't know any coffee script, just a little java script - so it's hard for me to start from scratch without having a sample file where I can see how different actions are performed. (e.g. the calling of the mentioned php script)

I will see what I can do with the mentioned guide :)

sweetpi commented 10 years ago

I think the sispmctrl-Plugin is very good example:

https://github.com/pimatic/pimatic-sispmctl/blob/master/sispmctl.coffee#L69-L82

You can simply call the php script with a shell command, like in changeStateTo, but with a command of the form: php /your/file.php arg1 arg2

koffienl commented 10 years ago

Sounds great guys :) Right now I would to let this pass, the next 4 weeks will be too busy for me to do anything with pi/pilight/pimatic

georg90 commented 10 years ago

i took a look at the file - seems not too hard to edit this ;-)

One Question left:

Do I need to create two devices? (One with the actual temp with +/- button and one with the ChangeMode buttons) Or is this controlled via the custom template?

Here is my config so far: http://pastebin.com/v3s9ssi4 When I want to Import the config Parameter to change the mode I use the following?

changeModeTo: (mode) ->
      if @mode is mode then return
      # Built the command
      command = "php {plugin.config.httpHost}"
      command += "?host={@plugin.config.host}&port={@plugin.config.port}&roomID={@plugin.config.roomID}" # and so on.. also add deviceNo and Temperatur/Mode etc.
      # and execue it.
      return exec(command).then( (streams) =>
        stdout = streams[0]
        stderr = streams[1]
        env.logger.debug stderr if stderr.length isnt 0
        @_setMode(mode)
      )
sweetpi commented 10 years ago

Do I need to create two devices? (One with the actual temp with +/- button and one with the ChangeMode buttons) Or is this controlled via the custom template?

You would need to create a custom template anyway (I can help with that, if the other stuff is working and if you will use git in the future :D). So just one device is needed.

Here is my config so far: http://pastebin.com/v3s9ssi4

I think you have to split up the config into one for the plugin config itself (host, port,...) and one for the devices (roomId, deviceId,...)

georg90 commented 10 years ago

Okay, I will do something about the config :) Using git means I should create a new plugin here? e.g. "pimatic-max-thermostat" Or just use my own?

Thanks for the help!

sweetpi commented 10 years ago

Using git means I should create a new plugin here? e.g. "pimatic-max-thermostat" Or just use my own?

I don't understand the question. I think it will be a plugin anyway, so it would be good if you upload your code to a github repository, so I can check it out if needed and submit patches.

georg90 commented 10 years ago

I don't understand the question. I think it will be a plugin anyway, so it would be good if you upload your code to a github repository, so I can check it out if needed and submit patches.

So I got you confused :D Sorry!

Here is my repository: https://github.com/georg90/pimatic-max-thermostat I just uploaded everything, and split the config into two parts. Haven't changed anything on the code though - this is for the weekend.

Hope this is what you meant?

sweetpi commented 10 years ago

Looks like a good start :)

Hope this is what you meant?

Yes the config part seems to be right.

georg90 commented 10 years ago

So I updated everything and tried with the plugin file. I haven't tested it yet (still need to set up development branch etc.) Also the max.php needs to be edited, which I will do later today ;-)

But for now I'm stuck on how to read the array given, writing the new values to the the config file and push changes to the framework. (every 5,10,60s?) --> Probably the interval needs a config value as well https://github.com/georg90/pimatic-max-thermostat/blob/master/maxthermostat.coffee#L54-L76 https://github.com/georg90/pimatic-max-thermostat/blob/master/max.php#L47-L49

Also I need a template..but the guide seems pretty good on that! :)

Edit: Also I might need to have two classes? Since I want to read the temperatur and mode in one and set temperatur and mode in another?

sweetpi commented 10 years ago

I've added some notices: https://github.com/georg90/pimatic-max-thermostat/commit/c3591087c2ff94e9074dcbb0268a72b44cacf844

georg90 commented 10 years ago

I've added some notices: georg90/pimatic-max-thermostat@c359108

updated the php syntax and tried to identify the indents. Also put in a method to read the json array (found online)

pimatic is loading the plugin, but it's not showing in the gui...how can I debug the plugin further?

georg90 commented 10 years ago

@sweetpi You offered help with the template and I could need a heads up..

I updated to plugin, it's loading now...

But I can't get into the template..I tried with the rpicam plugin as an example to create a custom template..but failed.

There is just this black box showing on the gui and the rest fails: image

So how I plan to implement this is having two bars that can be added:

Temperatur with +/- button

image

Mode Changer & quickly access the pre defined temperatures

image

sweetpi commented 10 years ago

Could you push your changes to github? Then I will take a look on it. The rpicam is currenty under heavy development, but the template is working, so it should be fine as an example.

Be sure to set the mode option from the mobile-frontend to development and always test in an new incognito tab to don't run into caching issues.

georg90 commented 10 years ago

git wasn't syncing...now it's up-to-date

georg90 commented 10 years ago

Thanks! I can include it :)

But when I try to change the temperature it gives me

2014-05-18 21:09:20 - error: Command failed:
2014-05-18 21:09:31 - error: Command failed:
2014-05-18 21:10:22 - error: Command failed:

I will look into this when I find some time :)

sweetpi commented 10 years ago

I had the same error. Thought it is because I didn't configed the php stuff.. Strange that there is no error message.

sweetpi commented 10 years ago

Some cross referencing for other: https://github.com/georg90/pimatic-max-thermostat/pull/1

sweetpi commented 10 years ago

Btw. great work so far. I hope we can move the php to javascript and use a persist connection some day.

georg90 commented 10 years ago

updated my branch - there was an error in max.php - everything is working from the console. But still on pimatic you cannot set any modes etc.. same error message.

I added this part: https://github.com/georg90/pimatic-max-thermostat/blob/master/maxthermostat.coffee#L112

But it's not shown in the log file? There is probably an error in the ajax call, since the action doesn't get called?

sweetpi commented 10 years ago

But it's not shown in the log file?

Its not shown because exec throws the Command failed: error and so the then part is never executed.

It has nothing to do with the ajax request. It just can't execute the php binary for some reasons. I will maybe make some tests later.

Its most likely that the path is wrong. Maybe try with the full file path.

georg90 commented 10 years ago

putting in the full path works

2014-05-19 13:49:16 - info: php /home/pi/pimatic-app/node_modules/pimatic-max-thermostat/max.php 192.168.0.59 62910 1 12345cf mode x undefined
2014-05-19 13:49:16 - info: Test

But the mode isn't set --> undefined

Edit: there was an error https://github.com/georg90/pimatic-max-thermostat/blob/master/maxthermostat.coffee#L123

has to be command += " mode x #{mode}" # set mode of the thermostat

I'll update soon

So mode change works, when I try to change the temperature I get:

TypeError: Cannot call method 'apply' of undefined
  at /home/pi/pimatic-app/node_modules/pimatic-rest-api/rest-api.coffee:41:15
  at callbacks (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/router/index.js:164:37)
  at param (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/router/index.js:138:11)
  at param (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/router/index.js:135:11)
  at param (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/router/index.js:135:11)
  at pass (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/router/index.js:145:5)
  at Router._dispatch (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/router/index.js:173:5)
  at Object.router (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/router/index.js:33:10)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Object.handle (/home/pi/pimatic-app/node_modules/pimatic/lib/framework.coffee:128:55)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Object.cookieSession [as handle] (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/middleware/cookieSession.js:120:5)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Object.json [as handle] (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/middleware/json.js:42:37)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Object.urlencoded [as handle] (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:41:37)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Object.cookieParser [as handle] (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:65:5)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Object.expressInit [as handle] (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/lib/middleware.js:30:5)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Object.query [as handle] (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/middleware/query.js:45:5)
  at next (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:193:15)
  at Function.app.handle (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/proto.js:201:3)
  at Server.app (/home/pi/pimatic-app/node_modules/pimatic/node_modules/express/node_modules/connect/lib/connect.js:65:37)
  at Manager.handleRequest (/home/pi/pimatic-app/node_modules/pimatic-mobile-frontend/node_modules/socket.io/lib/manager.js:565:28)
  at Server.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic-mobile-frontend/node_modules/socket.io/lib/manager.js:119:10)
  at Server.EventEmitter.emit (events.js:98:17)
  at HTTPParser.parser.onIncoming (http.js:2108:12)
  at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
  at CleartextStream.socket.ondata (http.js:1966:22)
  at CleartextStream.read [as _read] (tls.js:511:12)
  at CleartextStream.Readable.read (_stream_readable.js:320:10)
  at EncryptedStream.write [as _write] (tls.js:366:25)
  at doWrite (_stream_writable.js:223:10)
  at writeOrBuffer (_stream_writable.js:213:5)
  at EncryptedStream.Writable.write (_stream_writable.js:180:11)
  at write (_stream_readable.js:583:24)
  at flow (_stream_readable.js:592:7)
  at Socket.pipeOnReadable (_stream_readable.js:624:5)
  at Socket.EventEmitter.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:408:10)
  at emitReadable (_stream_readable.js:404:5)
  at readableAddChunk (_stream_readable.js:165:9)
  at Socket.Readable.push (_stream_readable.js:127:10)
  at TCP.onread (net.js:526:21)

Edit 2: Updated git!

sweetpi commented 10 years ago

https://github.com/georg90/pimatic-max-thermostat/pull/2

georg90 commented 10 years ago

my last post was deleted?!

It's working now - also setting (and showing in the gui) the temperature :) Two things:

https://github.com/georg90/pimatic-max-thermostat/commit/f5d9845d9cfcba5b930fec2dc148c70667ab7895

sweetpi commented 10 years ago

my last post was deleted?!

Sorry, wrong button. For the record from my mails:

working! Just missed one of your typos ;-) -still temperature is not shown in the gui.

and I get this error: 2014-05-19 17:31:59 - error: mode is not defined when I connect to the gui or update the temperature.

Screenshot: image

will have a look deeper into that later...

To the new ones:

The value of settemperature is not saved, so everytime you recall pimatic - it tries to set the temp to NaN (null) --> settemperature needs the default value from the config.

Take a look at: https://github.com/pimatic/pimatic-pilight/blob/master/pilight.coffee#L414-L415

The button highlight doesn't seem to work..just copied this from another part of pimatic -> can you help?`

Also get the buttons after render: https://github.com/pimatic/pimatic-mobile-frontend/blob/master/app/pages/index-items.coffee#L240-L243

koffienl commented 10 years ago

I'm a little confused .. How should I see the use of this Max! system? For me personally I would be able to open/close/modulte the state of a actuator. Reading the history of the posts above it sounds to me that you can control the Max! Cube LAN-Gateway wich would controll the actuators?

Can someone explain the what is currently possible with the system and pimatic?

georg90 commented 10 years ago

Possible: Change temp/mode of a thermostat via the pimatic gui

@sweetpi temp gets saved now with https://github.com/georg90/pimatic-max-thermostat/commit/d12c3f711a6006942e2ead818aef78ad2a4fee73

but it's not reading the values from the config on startup / refresh... how do I do this?

  1. check every (5min?!) if something changed
  2. check on refresh / initial load of the pimatic gui
sweetpi commented 10 years ago

On startup you could call changeModeTo and changeTemperatureTo on device construct, to submit the values to max.

Yes you could poll the values every 5min from the cube for now. The better way would be to move the php script stuff to pimatic so that a connection can be kept opened and it could be listened for changes.

Did you find out, how the official app does get notified?

I'm currently restructering some parts of pimatic and cleaning up / refactoring source so that the api should be fixed and better documented soon.

georg90 commented 10 years ago

Hi! Sorry for the late reply..

The official app doesn't get any infos from the thermostat, so it's just saving the set temperatur itself. I don't understand what you mean by "on device construct"?