genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
401 stars 157 forks source link

Danfoss Living Connect 014G0012 Faucet #120

Closed ErikDeBruijn closed 9 years ago

ErikDeBruijn commented 9 years ago

Hi! I'm really loving HomeGenie on an old netbook running Ubuntu and an Aeon Z-Stick 2. I currently use it for a basic Z-Wave based soft-alarm that I can turn on/off whenever I want to and where ever I am (with the HG Android App). Also, I can control several Hue Bulbs, which I can also control from my wrist using my pebble (directly to the hue bridge). Works great. Now there most important device left for this winter is heating. I'd love to schedule the thermostat to conserve energy.

I'm trying to get the 014G0012 edition of the Danfoss LivingConnect to work. It finds the module (nr. 9) and shows up in the dashboard: image

When I push the central button on the device I get this: screen shot 2015-02-05 at 21 17 45

In terms of UI everything looks good, it seems like I can change the set point, however it doesn't do anything yet: image

If I try to change the heating set point it says the following: image

If I go into the setup for the device I can "Get" some information from the device: screen shot 2015-02-05 at 21 22 14

Supported Classes Battery, 46, 81, Manufacturer Specific, 8F, 75, 43, Version, Wake Up, EF, 46

I found the device manufacturer string in the source code, too: http://www.pepper1.net/zwavedb/device/426 https://github.com/genielabs/HomeGenie/blob/977a92afd01f90317f4bc48abe0c7afb55fbd898/BaseFiles/Common/html/ext/zwave/pepper1db/0002_0005_0003.json

I hope this helps to get this device supported and working well.

Let me know if I should provide more information or what I could do to help!

genemars commented 9 years ago

currently homegenie only implement the following thermostat commands:

COMMAND_CLASS_THERMOSTAT_HEATING = 0x38,
COMMAND_CLASS_THERMOSTAT_MODE = 0x40,
COMMAND_CLASS_THERMOSTAT_OPERATING_STATE = 0x42,
COMMAND_CLASS_THERMOSTAT_SETPOINT = 0x43
COMMAND_CLASS_THERMOSTAT_FAN_MODE = 0x44,
COMMAND_CLASS_THERMOSTAT_FAN_STATE = 0x45,
COMMAND_CLASS_THERMOSTAT_SETBACK = 0x47,

as I don't own a z-wave thermostat cannot help much. Hopefully some developer with a device similar to yours can help adding the missing code.

ErikDeBruijn commented 9 years ago

Hi Gene, thanks for the reply. I would expect the SETPOINT 0x43 to do the job, this is indeed up to spec. Would it be helpful if I donated a Danfoss to you? Both to allow fixing it more easily than remotely and to give you a well deserved thank you.

genemars commented 9 years ago

Let's first try something. Open up a terminal and issue the commands:

 sudo /etc/init.d/homegenie stop
 cd /usr/local/bin/homegenie
 ./startup.sh

this will let you see debug messages from z-wave controller. Open a browser and enter the url:

http://localhost/api/HomeAutomation.ZWave/9/Thermostat.SetPointGet

then also try

http://localhost/api/HomeAutomation.ZWave/9/Thermostat.SetPointSet/Heat/21

Copy all the log you see in the terminal and paste them here. My concern about the last command is that it seems to contain some hard-coded value:

https://github.com/genielabs/HomeGenie/blob/master/MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Generic/Thermostat.cs#L215

this.nodeHost.SendRequest(new byte[] {
    (byte)CommandClass.ThermostatSetPoint,
    (byte)Command.ThermostatSetPointSet,
    (byte)ptype,
    0x09,  // <-- hard coded value:  0x09 - 3 bit precision, 2 bit scale (0 = C,1=F), 3 bit size -> Fahrenheit, size == 1
    (byte)temperature
});

To run HG again as a service, press CTRL+C and then enter the command:

sudo /etc/init.d/homegenie start
ErikDeBruijn commented 9 years ago

Hi Gene, thanks for the fast reply. I'm running HG in a screen now to be able to get this helpful output.

When doing Thermostat.SetPointGet I get this output:

2015-02-06T12:28:51.3411570+01:00   MIG.Gateways.WebServiceGateway  10.0.0.23   api/HomeAutomation.ZWave/9/Thermostat.SetPointGet   HTTP    GET
[12:28:51.342723] SPO < 01 09 00 13 09 02 43 02 05 04 AE
[12:28:51.368060] SPI > 06 01 04 01 13 01 E8
[12:28:51.368760] SPO < 06
[12:28:51.469979] SPI > 01 05 00 13 04 01 EC
[12:28:51.470948] SPO < 06
[12:28:51.644101] SPO < 01 09 00 13 09 02 43 02 05 04 AE
[12:28:51.671422] SPI > 06 01 04 01 13 01 E8
[12:28:51.672750] SPO < 06
[12:28:51.823347] SPI > 01 05 00 13 04 01 EC
[12:28:51.824536] SPO < 06
[12:28:51.946386] SPO < 01 09 00 13 09 02 43 02 05 04 AE
[12:28:51.974712] SPI > 06 01 04 01 13 01 E8
[12:28:51.976047] SPO < 06
[12:28:52.176524] SPI > 01 05 00 13 04 01 EC
[12:28:52.178311] SPO < 06
[12:28:52.348046] SPO < 01 09 00 13 09 02 43 02 05 04 AE
[12:28:52.378678] SPI > 06 01 04 01 13 01 E8
[12:28:52.379755] SPO < 06
[12:28:52.530109] SPI > 01 05 00 13 04 01 EC
[12:28:52.531448] SPO < 06
2015-02-06T12:28:52.5321700+01:00   HomeAutomation.ZWave    1   Z-Wave Controller   Controller.Status   Node 9 response timeout!
2015-02-06T12:28:53.5922610+01:00   MIG.Gateways.WebServiceGateway  83.162.198.83   api/HomeAutomation.HomeGenie/Logging/RealTime.EventStream/  HTTP    GET
[12:29:00.457118] SPI > 01 0A 00 04 00 04 04 30 03 FF 0C 31
[12:29:00.458159] SPO < 06

the Heat/21 command doesn't give any additional lines except the GET call:

2015-02-06T12:32:42.1130520+01:00   MIG.Gateways.WebServiceGateway  10.0.0.23   api/HomeAutomation.ZWave/9/Thermostat.SetPointSet/Heat/21   HTTP    GET
genemars commented 9 years ago

Press the button on the thermostat before issuing any command. Also the SetPointSet command was incorrect, sorry, try this one:

/api/HomeAutomation.ZWave/9/Thermostat.SetPointSet/Heating/21

g.

genemars commented 9 years ago

I see you made the donation already =) Thanks, I will then buy this device and make it work with hg. It will be more easy this way I guess. :+1:

ErikDeBruijn commented 9 years ago

@genielabs I'll try the new commands. Made the donation without any further obligation, but feel free to buy any gadget and keep doing what you're doing ;)

Using /api/HomeAutomation.ZWave/9/Thermostat.SetPointSet/Heating/21 gives IO in the terminal! We're making a lot of progress, because I can set the temperature IF I use the button before issuing the command. I found that using 21 or 22 actually resulted in 4deg C. So I guess I need to use Fahrenheit to send through the API. The conversion is trivial to automate though.

/api/HomeAutomation.ZWave/9/Thermostat.SetPointSet/Heating/21 without button press:

2015-02-06T13:15:30.0330540+01:00       HomeAutomation.ZWave    9       ZWave Node      Thermostat.SetPoint.Heating     21
[13:15:30.043473] SPI > 06 01 04 01 13 01 E8
[13:15:30.044611] SPO < 06
[13:15:30.194969] SPI > 01 05 00 13 0B 01 E3
[13:15:30.196780] SPO < 06
[13:15:30.334164] SPO < 01 0C 00 13 09 05 43 01 01 09 15 05 0B BD
[13:15:30.346987] SPI > 06 01 04 01 13 01 E8
[13:15:30.347982] SPO < 06
[13:15:30.448157] SPI > 01 05 00 13 0B 01 E3
[13:15:30.449512] SPO < 06
[13:15:30.635725] SPO < 01 0C 00 13 09 05 43 01 01 09 15 05 0B BD
[13:15:30.650178] SPI > 06 01 04 01 13 01 E8
[13:15:30.651583] SPO < 06
[13:15:30.801631] SPI > 01 05 00 13 0B 01 E3
[13:15:30.802920] SPO < 06
2015-02-06T13:15:30.8034070+01:00       HomeAutomation.ZWave    1       Z-Wave Controller       Controller.Status       Node 9 response timeout!

With button press a few seconds before loading the URL:

2015-02-06T13:21:56.5832480+01:00       MIG.Gateways.WebServiceGateway  10.0.0.23       api/HomeAutomation.ZWave/9/Thermostat.SetPointSet/Heating/60   HTTP    GET
[13:21:56.587110] SPO < 01 0C 00 13 09 05 43 01 01 09 3C 05 23 BC
[13:21:56.634536] SPI > 06 01 04 01 13 01 E8
[13:21:56.636345] SPO < 06
[13:21:56.686246] SPI > 01 05 00 13 23 00 CA
[13:21:56.687385] SPO < 06
2015-02-06T13:21:56.7886210+01:00       HomeAutomation.ZWave    9       ZWave Node      Thermostat.SetPoint.Heating     60

It actually displays 15.5 degrees (60 F)!

Any idea of how to make that button press to become unneeded? (since it kind of defeats the purpose of the whole exercise)

genemars commented 9 years ago

@ErikDeBruijn to make the button press unneeded, a WakeUp interval should be configured by using the "Setup" button on the module property popup. But also we need to implement this in HG:

https://github.com/genielabs/HomeGenie/issues/77

What is the output of SetPointGet ? It's not showing in your logs. I will be working on issue #77 and on automating the C/F conversion.

ErikDeBruijn commented 9 years ago

SetPointGet without pressing the button:

2015-02-06T13:49:19.9051080+01:00       MIG.Gateways.WebServiceGateway  10.0.0.23       api/HomeAutomation.ZWave/9/Thermostat.SetPointGet      HTTP    GET
[13:49:19.907201] SPO < 01 09 00 13 09 02 43 02 05 2E 84
[13:49:19.959321] SPI > 06 01 04 01 13 01 E8
[13:49:19.960708] SPO < 06
[13:49:20.010640] SPI > 01 05 00 13 2E 01 C6
[13:49:20.012028] SPO < 06
[13:49:20.208538] SPO < 01 09 00 13 09 02 43 02 05 2E 84
[13:49:20.212471] SPI > 06
[13:49:20.214384] SPO < 06
[13:49:20.264358] SPI > 01 04 01 13 01 E8
[13:49:20.416157] SPI > 01 05 00 13 2E 01 C6
[13:49:20.418094] SPO < 06
[13:49:20.610844] SPO < 01 09 00 13 09 02 43 02 05 2E 84
[13:49:20.617863] SPI > 06 01 04 01 13 01 E8
[13:49:20.619083] SPO < 06
[13:49:20.819435] SPI > 01 05 00 13 2E 01 C6
[13:49:20.820400] SPO < 06
[13:49:21.013070] SPO < 01 09 00 13 09 02 43 02 05 2E 84
[13:49:21.020887] SPI > 06 01 04 01 13 01 E8
[13:49:21.022247] SPO < 06
[13:49:21.122314] SPI > 01 05 00 13 2E 01 C6
[13:49:21.123490] SPO < 06
2015-02-06T13:49:21.1239840+01:00       HomeAutomation.ZWave    1       Z-Wave Controller       Controller.Status       Node 9 response timeout!

Pressing the button yields:

2015-02-06T13:50:11.6622040+01:00       HomeAutomation.HomeGenie.Automation     91      Automation Program      Program.Notification  {"Title":"Z-Wave Node WakeUp","Message":"<br>9 Basic Get"}
[13:50:11.663491] SPO < 01 09 00 13 09 02 20 02 05 34 FD
[13:50:11.711462] SPI > 06 01 04 01 13 01 E8
[13:50:11.712839] SPO < 06
[13:50:11.762648] SPI > 01 05 00 13 34 00 DD
[13:50:11.764156] SPO < 06

Then the API call leave the following in the logs:

2015-02-06T13:50:14.0122890+01:00       MIG.Gateways.WebServiceGateway  10.0.0.23       api/HomeAutomation.ZWave/9/Thermostat.SetPointGet      HTTP    GET
[13:50:14.013681] SPO < 01 09 00 13 09 02 43 02 05 35 9F
[13:50:14.021417] SPI > 06 01 04 01 13 01 E8
[13:50:14.023579] SPO < 06
[13:50:14.073703] SPI > 01 05 00 13 35 00 DC
[13:50:14.075643] SPO < 06

There is no json output from the HTTP call like with some other API commands like HomeAutomation.PhilipsHue/1/Control.Toggle'.

ErikDeBruijn commented 9 years ago

I've set the device to wake every 301 seconds (to check if reading would yield this value). It should be waking up but I don't seen any events.

I read ( on another forum ) that the device should check periodically for the desired SetPoint.

DANFOSS CHECKING IN AGAIN AND CORRECTLY MODIFYING THE TEMPERATURE SETTING OF THE UNIT (DISPLAY VALUE CHANGES TO 17):
18 aug. 2013 20:25:16
Z-Wave Debug RCVD requestBatteryLevel: 01 09 00 04 00 0D 03 80 03 57 28
Z-Wave Debug . . requestBatteryLevel: node 013, level 87
Z-Wave received "013 - Setpoint Thermostat" status update battery level 87%
Z-Wave Debug RCVD requestSetpointVal: 01 0C 00 04 00 0D 06 43 03 01 42 08 98 6F
Z-Wave Debug . . requestSetpointVal: node 013, endpoint None, type 1, raw value 4208...
Z-Wave Debug . . requestSetpointVal: 22.00 °C (float: 22.000000)
Z-Wave received "013 - Setpoint Thermostat" heat setpoint is 22.00 °C
Z-Wave Debug RCVD requestReply1: 01 0A 00 04 00 0D 04 46 08 00 7F C9 (hex)
Z-Wave Debug RCVD nodeAwake: 01 08 00 04 00 0D 02 84 07 7F
Z-Wave Debug . . nodeAwake: node 013
Z-Wave Debug SENT setHeatSetpoint: 01 0C 00 13 0D 05 43 01 01 01 11 05 E2 5C
Z-Wave sent "013 - Setpoint Thermostat" decrease heat setpoint to 17.0°
Z-Wave Debug . . nodeAwake: skipping battery check (next check in 713 mins)
Z-Wave Debug SENT goToSleep: 01 09 00 13 0D 02 84 08 05 E3 80
genemars commented 9 years ago

So it seems that the SetPointGet in HG is missing one byte parameter that should be the type of setpoint to get. So after fixing, the command should be like this

/api/HomeAutomation.ZWave/9/Thermostat.SetPointGet/Heating

and the output that hg should send, something like

SPO < 01 09 00 13 09 03 43 02 01 05 35 9F

Unfortunately the fix to the Thermostat.SetPointGet requires modification to HG source code. If I make the fix, do you have any chance of running hg from source and test? Also, once the device wakes up, HG should send this command but the Z-Wave Wake Up automation program does not consider the device type Thermostat. So there's some code to be added to that program. I will give you the missing code so you can test. This update can be done entirely within hg web UI (from Automation section).

ErikDeBruijn commented 9 years ago

@genielabs I'd be happy to run a source version if that helps. So basically I need to set up a different homegenie version from git? And after that add an alternative Automation program?

genemars commented 9 years ago

@ErikDeBruijn I will commit the fix to this repository, so all you have to do is testing that everything is working. I'm fixing the SetPointGet right now, I will commit in half an hour or so. Is it ok for you? I will also add needed code to the Wake Up program.

ErikDeBruijn commented 9 years ago

Okay, so I will git clone it and then pull again when you say so. Let me know how to install/run a debug version once you're ready.

genemars commented 9 years ago

@ErikDeBruijn ok pull the latest source. To run from source code you have to install MonoDevelop

sudo apt-get install monodevelop

after installing, you can open the _HomeGenie_Linux/HomeGenieLinux.sln file by double clicking on it. The click the Play (run) icon in the MonoDevelop toolbar. This will run homegenie. It will be probably bind on HTTP port 8080. So you access it with htttp://localhost:8080 Then you can test both if HG query the thermostat setpoint and battery after you press the button on the device and the SetPoint get command directly from the browser as explained before. You'll have to enable the Z-Wave interface and add the module. Stop homegenie service that is already running before debugging from source.

ErikDeBruijn commented 9 years ago

Is there a CLI way to load mono or should I use the laptop? (I could, but its keyboard is just too small to type correctly)

genemars commented 9 years ago

sorry forgot to mention that before clicking the "Play" button you have to build the solution by pressing CTRL+F7 or by right-clicking on the HomeGenie_Linux root node on the solution explorer and choose the "Rebuild all" option.

genemars commented 9 years ago

if you have already installed homegenie on Ubuntu desktop just install monodevelop. There's not script to build from CLI.

ErikDeBruijn commented 9 years ago

Got mono installed, clicked the .sln file, pressed Ctrl-F7. It's half way done building...

ErikDeBruijn commented 9 years ago

Okay, it's done. How do I "start" it? From the IDE? I'm getting a System.IO.FileNotFoundException...

ErikDeBruijn commented 9 years ago

If you want we can share a session on the laptop. Do you use VNC or teamviewer or such?

genemars commented 9 years ago

I will install teamviewer.

ErikDeBruijn commented 9 years ago

Okay, it's installing here (laptop is not particularly fast, that's why it's running as Home Controller ;) )... progress bar is crawling forward...

ErikDeBruijn commented 9 years ago

okay, window disappeared. PWD changed. Can I invite you instead? What's your ID?

genemars commented 9 years ago

ok... just a second... installing dependencies

ErikDeBruijn commented 9 years ago

okay, the new pwd is 3890.

genemars commented 9 years ago

504 933 262

genemars commented 9 years ago

ok I'm in

ErikDeBruijn commented 9 years ago

Are you hearing my audio or not?

genemars commented 9 years ago

I don't have a mic, not hearing any audio anyway.

genemars commented 9 years ago

is the z-stick connected?

ErikDeBruijn commented 9 years ago

it is

genemars commented 9 years ago

very slow...

ErikDeBruijn commented 9 years ago

yep. But slightly better than a RPi, not? Let me know if I need to unplug + replug it. And know that the official version of Homegenie is located in /usr/local/bin/homegenie if you want to test if it finds the stick there...

genemars commented 9 years ago

sure it is better than RPi =) not it will work

genemars commented 9 years ago

not=now

ErikDeBruijn commented 9 years ago

you needed it to be able to suid root?

genemars commented 9 years ago

yes because access to /dev/ttyUSB0 required it

ErikDeBruijn commented 9 years ago

I see. I'm working with ttyACM0 with Ultimaker 3D printers. So I know a bit about ttys. They run open source firmware and desktop software that we make (Marlin and Cura). The hardware is also open sourced.

genemars commented 9 years ago

please push the button

ErikDeBruijn commented 9 years ago

done

genemars commented 9 years ago

push the button again

ErikDeBruijn commented 9 years ago

just did it again, 10 sec. ago.

genemars commented 9 years ago

is it 22.5 ?

ErikDeBruijn commented 9 years ago

true

ErikDeBruijn commented 9 years ago

Just FYI: It's not -5.7 degrees here.

ErikDeBruijn commented 9 years ago

now it set it to 4'C

genemars commented 9 years ago

found and fixed the mistery of 0x42 value =) btw I think I'm going to buy the film ;) (ain't a very good book reader)

genemars commented 9 years ago

@ErikDeBruijn I made some research and tried to figure out how to make this work. I hope did not screw up everything :) but you can pull the latest code and test both SetPoint Get and Set. If this is not working, another teamviewer session may definitely help.

genemars commented 9 years ago

@ErikDeBruijn oopss... I had to make another a smal fix.