Samstag, 6. Dezember 2014

WiFi RGB LED controller + FHEM + Pebble

Since I want more control over my heating, I looked into it and decided to give FHEM a try, but more on that later when I actually get the hardware etc. But while looking through some FHEM stuff, I came across WiFi controllers for RGB strips. In the past I already used a Raspberry Pi and a self made IR adapter, but that was rather crude and inefficient.

So I went to Amazon and bought the following:
NEUER LW-12 WIFI WLAN LED RGB STRIPS CONTROLLER für iPhone, iPad, iOS, Android 24V *Weiß*
and
Besdata 5m 500CM RGB 5050 300 SMD LED Strip Leiste Streifen + 44 Key Fernbedienung + Netzteil 12V 6A 72W- RGB - Wasserdicht - PL709A+EU

I recommend you to get a waterproof strip regardless where you install it, because it is easier and safer to install, since you can't get shocked. The normal ones are just open circuitry.

After installing the LED strip and the controller, I set up the controller and was able to control the light with my smartphone and tablet, which is already quite nice. But having to take out the phone and turning on the light is not as efficient as turning a switch.
 I also noticed another "feature" of the controller: It acts as a WiFi repeater. Therefore, it is extremely important to change the standard password of the built in AP, which is always the same. You can do that through the App or web interface. I haven't found a way to turn it off and also the channel selection doesn't work for me and always uses channel 13.

Connecting it to FHEM was rather easy. Download the latest  LW12 from here or WifiLight from here. Then put one or both into your fhem/FHEM folder.

After that just enter:
define your_chosen_name WifiLight RGB LW12:ip.to.your.controller
or
define your_chosen_name LW12 ip.to.your.controller  
For most cases LW12 should be better, since it is just for the LW12 and can use its back channel etc. You can also use them side by side.

 After that I can now control the light with nearly anything I want...

So I made an APP for my Pebble. You can find it here on Github.
If you want to use it, just import it to cloudpebble.net and change the vars etc. to fit into your network etc.

On my Pebble, I added my APP as a quick launch and now I just have to hold the up button and press it again to turn on the light, regardless where I am in the room.

7 Kommentare:

  1. Hallo, erst mal klasse Blog!
    Ich hab genau die gleichen Gegebenheiten. Ich möchte gerne mit der Pebble das Licht schalten. Habe mir dazu einen FHEM Server auf meiner Fritz box installiert und eingerichtet. Soweit funktioniert alles...ich kann es per Browser fernsteuern. Nur mit der Pebble bekomme ich es nicht hin.

    Meine Konfiguration:
    WifiLight.pm mit den Einstellungen: define lampe WifiLight RGB LW12:192.168.178.32
    attr lampe room Zimmer

    FB: 192.168.178.1

    Einstellungen in deiner App:
    //change IP, Port and the Name of the device you want to control depending on your setup.
    var fhemIp = '192.168.178.1';
    var fhemPort = '8083';
    var deviceName = 'lampe';

    Hast du noch einen Tipp was ich falsch mache? Bin absoluter Anfänger in Sachen Pebble und FHEM. Vermute, dass der devicename nicht stimmt. (Versucht mit WifiLight_lampe und Zimmer)

    Liebe Grüße Peter

    AntwortenLöschen
    Antworten
    1. Hallo Peter,
      Ich gehe mal davon aus, dass dein Smartphone im Lan auf FHEM zugreifen kann.
      Der Name sollte eigentlich einfach lampe sein, wie du es im define angegeben hast. Nichts mit Wifilight oder Raum oder so...

      Versuch mal im Browser (am besten vom Smartphone aus) http://192.168.178.1:8083/fhem?cmd=set%20lampe%20on zu öffnen. Damit sollte das Licht angehen (on kann auch durch jeden anderen Befehl ersetzt werden). Wenn das geht und von der Pebble aus nicht, dann liegt der Fehler irgendwo bei der Pebble APP.
      Wenn es nicht funktioniert, dann ist wohl wirklich was mit der FHEM Konfiguration nicht in Ordnung. Wenn das schalten von der Weboberfläche weiterhin möglich ist, dann mach doch mal nen Screenshot von der Detailansicht (da wo alle Internals Readings und Attributes angezeigt werden).

      Löschen
  2. Hallo, danke für die schnelle Antwort.
    Habe den Link über mein Smartphone geöffnet und es ging sofort das Licht an.
    Über die Pebble geht es weiter nicht (https://dl.dropboxusercontent.com/u/17810933/pebble.jpg) So sieht meine Konfiguration aus.
    Wenn du die Detailansicht von der fhem.cfg meinst dann hier: https://dl.dropboxusercontent.com/u/17810933/fhemcfg.jpg
    Sieht für mich alles richtig aus oder?

    AntwortenLöschen
    Antworten
    1. Auf den ersten Blick sieht für mich auch alles richtig aus. Habe eben mal meine aktuelle Version zu github gepusht. Die vorherige Version hat auch funktioniert (bis auf Grün wegen dem Umlaut), aber zum Debugging ist es besser, wenn du diese neue Version benutzt.

      Dann versuchen wir mal den Bug zu finden:
      Hast du ein Android oder iPhone Gerät?
      Hast du die neueste App und Firmware Version?
      Was sagt der log der Pebble App?
      Füg zum testen folgendes zu deiner fhem.cfg hinzu und ändere in der Pebble App nur die IP zu 192.168.178.1 und sonst nichts:

      define WifiLight_Martin WifiLight RGB LW12:192.168.0.32
      attr WifiLight_Martin colorCast 0, -20, -20, -25, 0, -10
      attr WifiLight_Martin defaultColor 15,100,100
      attr WifiLight_Martin webCmd RGB
      attr WifiLight_Martin whitePoint 1, 0.75, 0.25
      attr WifiLight_Martin widgetOverride RGB:colorpicker,RGB

      Löschen
  3. Hat auch nicht geklappt!
    Habe ein Iphone 6 Könnte es aber auch mit einem Android gerät testen.
    Iphone App 2.6.4 Smartwatch 2.9
    Pebble Log Auszug: [HANDY] pebble-app.js:?: JS: LIGHT: (+) [menu 4] : [card 1],[menu 4]
    [HANDY] pebble-app.js:?: JS: LIGHT: JavaScript Error:
    send@[native code]
    at ajax (lib/ajax.js:114:11)
    at execute (app.js:42:7)
    at app.js:92:12
    at emitToHandlers (lib/emitter.js:121:21)
    at emit (lib/emitter.js:145:35)
    at emit (ui/window.js:273:24)
    at emit (ui/menu.js:301:14)
    at emitSelect (ui/menu.js:349:16)
    at onPacket (ui/simply-pebble.js:996:22)
    [HANDY] pebble-app.js:?: JS: LIGHT: JavaScript Error:
    send@[native code]
    at ajax (lib/ajax.js:114:11)
    at execute (app.js:42:7)
    at app.js:92:12
    at emitToHandlers (lib/emitter.js:121:21)
    at emit (lib/emitter.js:145:35)
    at emit (ui/window.js:273:24)
    at emit (ui/menu.js:301:14)
    at emitSelect (ui/menu.js:349:16)
    at onPacket (ui/simply-pebble.js:996:22)
    [HANDY] pebble-app.js:?: JS: LIGHT: JavaScript Error:
    send@[native code]
    at ajax (lib/ajax.js:114:11)
    at execute (app.js:42:7)
    at app.js:92:12
    at emitToHandlers (lib/emitter.js:121:21)
    at emit (lib/emitter.js:145:35)
    at emit (ui/window.js:273:24)
    at emit (ui/menu.js:301:14)
    at emitSelect (ui/menu.js:349:16)
    at onPacket (ui/simply-pebble.js:996:22)

    AntwortenLöschen
    Antworten
    1. Versuch es mal mit nem Android. Wenn ich mich nicht täusche, erlaubt Apple es nicht beliebigen Code auszuführen. Deshalb müssen alle Javascript Apps in die Pebble APP direkt integriert werden. Da könnte irgendwo das Problem liegen. Wenn du Glück hast, liegt es aber auch nur an einer unterschiedlichen Verarbeitung des Befehls. Versuch mal einem Knopf direkt die im Browser funktionierende URL http://192.168.178.1:8083/fhem?cmd=set%20lampe%20on zuzuweisen. Das müsste dann in etwa so aussehen:

      main.on('click', 'up', function(e) {
      ajax({ url: 'http://192.168.178.1:8083/fhem?cmd=set%20lampe%20on'});
      });

      Ich war selbst erstaunt, dass Groß und Kleinschreibung und Leerzeichen in einer URL funktioniert haben. Ich hoffe mal, dass es daran liegt. Ich hatte überlegt, ob ich die saubere Lösung mit %20 statt Leerzeichen usw. benutzen sollte, habe es dann aber nicht getan, da es auch so funktioniert hat und es wesentlich einfacher zu lesen ist.

      Löschen
  4. Very nice starting point for other projects using a peppble with FHEM. Thanks a lot!

    AntwortenLöschen