element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Home Automation
  • Challenges & Projects
  • Project14
  • Home Automation
  • More
  • Cancel
Home Automation
Blog OpenHAB 2 with Matrix Creator and RasPi 3 A+: Everloop and demo
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Home Automation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jomoenginer
  • Date Created: 15 Mar 2019 7:12 AM Date Created
  • Views 1031 views
  • Likes 6 likes
  • Comments 2 comments
  • homeautomationch
  • mqtt
  • python
  • rpiintermediate
  • matrix labs
  • arduino mkr1010
  • matrix-lite-py
  • matrix creator
  • raspberry pi 3 a+
Related
Recommended

OpenHAB 2 with Matrix Creator and RasPi 3 A+: Everloop and demo

jomoenginer
jomoenginer
15 Mar 2019
image

Home Automation

Enter Your Electronics & Design Project for a chance to win a $100 Shopping Cart!

Back to The Project14 homepage image

Project14 Home
Monthly Themes
Monthly Theme Poll

 

Overview

This is my last post for the Home Automation Project14 event due to time constraints.  My intention was to implement controlling the GPIO connections from P2 on the MATRIX Creator via openHAB, but that is not quite working at this point, so I am moving to just the Everloop control which I already have configured in openHAB.  This control from openHAB is from the Exec Binding calling python scripts using the matrix-lite-py interfaces.   The Basic UI is used from openHAB to send the commands to the MATRIX Creator.

Previous Posts:

OpenHAB 2 with Matrix Creator and RasPi 3 A+: Intro

OpenHAB 2 with Matrix Creator and RasPi 3 A+: MATRIX Lite Python

OpenHAB 2 with Matrix Creator and RasPi 3 A+: OpenHAB 2 MQTT Binding

OpenHAB 2 with Matrix Creator and RasPi 3 A+: OpenHAB 2 Exec Binding

OpenHAB 2 with Matrix Creator and RasPi 3 A+: GPIO and Postmortem

 

MATRIX Lite Python

Using the example that came with the MATRIX Lite Python interfaces, I have created a couple of methods that can turn on and off the Everloop LEDs as well as control the color and brightness.

 

   Python Script uses a Dictionary to sed specific colors.

ledMatrix = {'red': {'ledr' : 1, 'ledg' : 0 , 'ledb' : 0, 'ledw' : 0},
            'green': {'ledr' : 0, 'ledg' : 1 , 'ledb' : 0, 'ledw' : 0},
            'blue': {'ledr' : 0, 'ledg' : 0 , 'ledb' : 1, 'ledw' : 0},
            'white': {'ledr' : 0, 'ledg' : 0 , 'ledb' : 0, 'ledw' : 1},
            'off': {'ledr' : 0, 'ledg' : 0 , 'ledb' : 0, 'ledw' : 0},
            'on': {'ledr' : 1, 'ledg' : 1 , 'ledb' : 1, 'ledw' : 1}
            }


## LED Example ##


def runEverloop(self, color):


self.everloop = hal.everloop()


color = color.lower()


print ("Color: %s" % color)


for i in range(self.everloop.ledCount):


#led = hal.led(0,0,0,0)#led.r led.g led.b led.w


led = hal.led(ledMatrix.get(color, {}).get('ledr'),


ledMatrix.get(color, {}).get('ledg'),


ledMatrix.get(color, {}).get('ledb'),


ledMatrix.get(color, {}).get('ledw'),


)#led.r led.g led.b led.w


self.leds.append(led)


del led


self.everloop.set(self.leds)

 

   Python method to dynamically set LED colors:

## LED Color set ##


def setEverloop(self, colorVal):


self.everloop = hal.everloop()


print ("Color: %s" % colorVal)


colorList = colorVal.split(":")


for i in range(self.everloop.ledCount):


#led = hal.led(0,0,0,0)#led.r led.g led.b led.w


led = hal.led(int(colorList[0], 16),


int(colorList[1], 16),


int(colorList[2], 16),


int(colorList[3], 16)


)#led.r led.g led.b led.w


self.leds.append(led)





del led


del colorList


self.everloop.set(self.leds)

 

Sorry, I am not sure what is happening with the formatting of the code but I do not have time to fix they way the code looks.

openHAB Items config

Switch SetELoopRed "EverLoop Red" { channel="exec:command:eloop_color_red:online" }
Switch SetELoopBlue "EverLoop Blue" { channel="exec:command:eloop_color_blue:online" }
Color SetELoopColor "EverLoop Color" <slider>

 

openHAB Sitemap config

Frame label="EverLoop" {


Switch item=SetELoopRed label="eLoop Red" icon="colorpicker"


Switch item=SetELoopBlue label="eLoop Blue" icon="colorpicker"


}


Frame label="EverLoop Color" {


Colorpicker item=SetELoopColor label="eLoop color" icon="colorpicker"

}

openHAB Rules

import org.eclipse.smarthome.core.library.types.HSBType

var String eLoopCmd = '/usr/bin/python3 /opt/openhab2/conf/scripts/newTempScript.py '
//var String eLoopColor = '/usr/bin/python3 /opt/openhab2/conf/scripts/newTempScript.py ' + '--color' + ' '

rule "Set Eloop Red"
when
    Item SetELoopRed received command
then
    if(receivedCommand == ON) {
        var String eLoopRed = eLoopCmd + '-e' + ' \"'+ 'red' + '\"'
        logInfo("SetELoopRed", "setting everloop to red")
        executeCommandLine(eLoopRed)
    }
    else {
        var String eLoopOff = eLoopCmd + '-e' + ' \"'+ 'off' + '\"'
        logInfo("SetELoopRed", "setting everloop to off")
        executeCommandLine(eLoopOff)
    }
end

rule "Set Eloop Blue"
when
    Item SetELoopBlue received command
then
    if(receivedCommand == ON) {
        var String eLoopBlue = eLoopCmd + '-e' + ' \"'+ 'blue' + '\"'
        logInfo("SetELoopBlue", "setting everloop to blue")
        executeCommandLine(eLoopBlue)
    }
    else {
        var String eLoopOff = eLoopCmd + '-e' + ' \"'+ 'off' + '\"'
        logInfo("SetELoopBlue", "setting everloop to off")
        executeCommandLine(eLoopOff)
    }
end

rule "Set Eloop Color"
when
    Item SetELoopColor received update
then
    logInfo("SetELoopColor", "Get Color")
    var hsbValue    = SetELoopColor.state as HSBType
    var brightness  = hsbValue.brightness.intValue
    var redValue    = ((((hsbValue.red.intValue * 255) / 100) * brightness) / 100).toString 
    var greenValue    = ((((hsbValue.green.intValue * 255) / 100) * brightness) / 100).toString 
    var blueValue    = ((((hsbValue.blue.intValue * 255) / 100) * brightness) / 100).toString 
    logWarn("Red", redValue)
    logWarn("Green", greenValue)
    logWarn("Blue", blueValue)
    var String cmd = eLoopCmd + '-c' + ' ' + '\"' + redValue + ':' + greenValue + ':' + blueValue + ':' + '0' + '\"'
    logInfo("SetELoopColor", cmd)
    executeCommandLine(cmd)

end

 

 

  openHAB Basic UI Everloop Controls

image

 

Well, that is about it.    This has been interesting, and as always I wished I had more time to get more done, but I at least I was able to this much configured.   There is still a whole host of things that can be done with this config and I will continue to work with it.  I'd like to thank Tariq and element14 for providing me with the MATRIX Creator and Raspberry Pi 3 A+ for the project.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • Sign in to reply

Top Comments

  • aabhas
    aabhas over 6 years ago +1
    jomoenginer Great series of blog with Matrix Creator and Raspberry Pi and also Thanks a lot for help provided in the discussion . Aabhas Senapati
  • aabhas
    aabhas over 6 years ago

    jomoenginer

    Great series of blog with Matrix Creator and Raspberry Pi and also Thanks a lot for help provided in the discussion .

    Aabhas Senapati

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dixonselvan
    dixonselvan over 6 years ago

    jomoenginer Excellent series of work! I too couldn't get that much time to put into my project what all I have planned. The Everloop demo was so satisfying to watch in particular the rainbow demo.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube