IR Remote Control Mote

Started by gurari, August 29, 2015, 12:34:31 PM

gurari

Hello,
I'm not sure here is the right position for this topic but it can be moved any time ;)
So I want to ask Felix if he is planing making some kind of IR Remote Control Mote and adding it to the gateway database.
It would be very useful for home automation projects, because with one mote you can control a lot of electronics in one room. Personally I'm planing controlling Air Conditioners, TVs, Satellite Receivers, etc.
Recently I had time to put together the code for controlling the AC's (there was a lot of information about DAIKIN air conditioners, but because of my not good programming level it took me more time) and all is working like charm but now I'm facing another difficulty - writing the code in JS for the Felix's GATEWAY.
Researching the DAIKIN IR codes I found a very cute example of IR controlling gateway - http://automatico.jeckyll.net/ user:test pass:test .
So I'm wondering if Felix is planning adding such a feature in the GATEWAY?

Felix

gurari,
I am not sure how to answer. If I plan? I would like to but it's not quite on my radar right now.
I guess one of the reasons is that the gateway should not really be assumed to be in a central visible place in the home. It's the heart of everything and it should not be messed with by kids and accidentally unplugged or shut off etc.
I think the better approach is to make some kind of remote control device if you really need to. Then that could serve as a IR to gateway bridge, or vice versa.

However the whole point of the Gateway interface is to be able to use it from your smart phone or tablet. You could use a wall mounted tablet for controlling everything. You can add custom nodes by writing a little javascript in metrics.js if it's not already defined for you. Your IR node could be in the room where your IR devices are and you can control them via the gateway interface. Otherwise if you just want direct IR control you don't need any gateway or any of this, but you also could not control the IR devices remotely when you're away.

gurari

Hello Felix,
I agree with you about the role of the gateway (like phisical part). It was my mistake not writing it clear. Unfortunately my English is not ate very high level. So by "Gateway" I was meaning the interface (software part that we are using through the browser). I have already done some prototype nodes with IR diodes and temp/humi sensors. In the pas I was using them with OpenHAB and they were working good. In these days I was only sending On/Off commands (just repeating). Whey you released you Gateway code for the public I started using it instead of OpenHAB because I like the simplicity and lightness of your platform. So now I have to add some code in the metrics.js to be able to control the nodes I've prepared for IR controlling. To say the truth I was looking for someone to help me with this because my knowledge of JavaScript is not good ;) Sometimes I'm lazy.
Tomorrow I'm leaving for USA trip so when I came back I'll do some try and error stuff with the javascript code in the metrics.js and then I'll IRnode in the Gateway automation interface

Felix

There are many different examples in metrics.js that cover a lot of ground in terms of metrics flexibility.
I can try to help but you'll need to include more specific details of how your IR nodes work.
I think you just need to define 2 controls for ON and OFF and make them send specific messages to your target node. Look at how other node controls are defined, SwitchMote or GarageMote or Sprinklers, etc.

gurari

I want to make it more "complex", something like on the attached picture.
So I'll be needing a form that have to send all the data from it in a string - something like this - CMD:P:0,M:0,T:0,F:20,V:1,H:1. All the info about the AC functions will be in the string. The system in attached picture is working like that. when you select all the things you want - temp, heat, fan, etc.- you are pressing the SET button and the command is sent.
So the <FORM> thing is the problem to me :) I've already saw how to make a button to send a ON/OFF command. Now have to learn the rest ;)

Felix

Sure, you can have all those buttons if you want, just set them up with specific commands in metrics.js

gurari

So the USA trip is over :( Now I'll try to find some time to do the needed things to insert the code in the metrics.js to make IRnode working :) When I have some results I'll post them here.

gurari

It's me again.
The weather is getting colder and colder and I have to start working over the IRMote again. I've tried to modify the code in the metrics.js but unofrtunately it is too complex for me at the moment. My goal is somehow to send a message to the IRMote that is constructed from sum of several selectable values.
For example I have to select the Power state (ON/OFF), Temperature, Fan Speed, Mode(Heat/Coll/Dry..), etc and at the end to send them in one message that sould look somethong like that - CMD:P:0,M:0,T:0,F:20,V:1,H:1.
Can someone give me directions how to make this possible, because air conditioners wants all the information from the remote to be sent in one message. At the and I can use some fixed messages but I is kind of low tech only to repeat the commands. My skills on JavaScript are very basic so I need a little push-up to start ;)

Thanks in advance
Joro

gurari

So I've decided for the moment to have some preset conditions for the AC and started working on the code.
To send the various commands to the AC I finished with this kind of message to be send:
CMD:P:1,M:0,T:22,F:4,V:1,H:1

And here goes the hard part for me.  I have problem parsing the metrics so I can match them and update the status of the button.
If I use short message I managed to make all work, but when I have to match the real message I face problems.
AC_ON  : { name:'Status', regexp:/CMD\:0/i, value:'OFF'},
 AC_OFF : { name:'Status', regexp:/CMD\:1/i, value:'ON'},

Can someone help me with this problem?

Felix

The pattern of the matches in my gateway.js script is space separated, not comma separated. Also a metric is a name followed by : followed by value. So first you need to reformat your packet to remove any redundancies and replace commas, to something like:

P:1 M:0 T:22 F:4 V:1 H:1

Next you need to replace the metric names that have already been defined for P and H and F, make them unique, or they may be matched by the first definition in the list (parser matches on the first matching expression and stops).
If all your metrics are numeric and do not require any specialties (graphing etc) the matching entry should be like this:

BLA : { name:'BLA', regexp:/BLA\:([\d\.]+)/i, value:'', unit:'', pin:1, },

This will match an expression like:

BLA:numeric

The events section would be where you define actions taken based on values received, if you need that.
I hope this helps...

gurari

Thank you for the reply Felix.
Today I've started to explore your code in metrics.js. Also read about the regular expressions - this is sometuhing completely new for me.
I've corrected my packets to match your code and now step by step I'm making progress. The code for WiFi thermostat also looks very good for my needs. With a little more reading and tests I'll understand it so I'll be able to use some conditions for the events.
I'll share some pics when I have more buttons working like I want :-)

And BTW thank you one more time for the great products you are making!

gurari

Finally today I had some time to post a little update.
I managed to make some buttons with preset commands for the AC that I use mostly especially if I'm out and want to set some comfort. Maybe I'll add some buttons for TV and multimedia later but I have to figure out how it will look better. I've added and a DTH22 sensor for room environment data. Here are some prototype photos




WhiteHare

Nice photo!  I think anyone who has (or has ever had) either a mini split or a window mounted unit can appreciate the utility of your device.

What does "NOISE" refer to?  Are you using a microphone to monitor whether the HVAC is running?

gurari

Quote from: WhiteHare on December 21, 2015, 04:47:46 PM
Nice photo!  I think anyone who has (or has ever had) either a mini split or a window mounted unit can appreciate the utility of your device.

What does "NOISE" refer to?  Are you using a microphone to monitor whether the HVAC is running?

I'm from Europe and nowadays in my country for heating/cooling the house we are using mainly mini split systems for every room so I've decided the node that is logging the temp and humidity to be able to control the AC. Maybe I'll add some lines for controlling other IR units so when I go out I just can told all devices to switch off or something like that.

The NOISE is state of the blower - POWERFUL/QUIET/SILENT/NIGHT. I was wondering how to call it and because it is related to the nose making the unit for the moment variable is called NOISE

Sergegsx

Nice work gurari!

I also use an IR control, in this case via an Arduino MEGA and a ESP8266. The reason for using the MEGA is that the IR codes are extremely long for the space of the atmega328.

Now I need to upgrade it to the Moteino hardware to make it more compact and keep all node styles consistent as ESP8266 is great for some things but I am switching over to Moteino all my nodes.

I added 2 LDR sensor to the small box of the hvac unit, in charge of reading temperature, receive IR and show 2 leds (on/off and running). By adding this two sensors I know when the HVAC system has received correctly my IR code.