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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog PDU #12 - Details: Home Assistant Integration [Upcycle It Challenge]
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jasonwier92
  • Date Created: 23 May 2017 5:44 PM Date Created
  • Views 1066 views
  • Likes 4 likes
  • Comments 3 comments
  • home automation
  • home assistant
  • upcycle it
  • upcycled_pdu
  • intel edison
Related
Recommended

PDU #12 - Details: Home Assistant Integration [Upcycle It Challenge]

jasonwier92
jasonwier92
23 May 2017

One of my goals was to integrate this from Home Assistant. Home Assistant (HASS) is open-source home automation package written in Python. Check it out. It can talk to several devices using multiple protocols. I use mine to automate my lights to turn on and off in the kitchen (under counter that are on all night) and to turn on my wife's coffee machine (not working now, because the Belkin WeMo Switch is broke).  Since HASS currently has access to many things in my house, it would be nice that my PDU project would play with it. I have modified my Node-Red setup on my Edison to send out and receive proper MQTT to integrate right into HASS.  Also in this update, I will show you the starts of the new web interface I am designing.

 

Demo Of This Working

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

 

Home Assistant Config

Here is one outlet configured.  I have 7 more files just like it.

::::::::::::::
switches/mqtt/toweroulet01.yaml
::::::::::::::
  platform: mqtt
  name: "Tower PDU Outlet1"
  state_topic: "tower/outlet0001/status"
  command_topic: "tower/outlet0001/control"
  qos: 0

 

My Tower Power Group:

  Tower:
    name: "Tower"
    entities:
      - switch.Tower_PDU_Outlet1
      - switch.Tower_PDU_Outlet2
      - switch.Tower_PDU_Outlet3
      - switch.Tower_PDU_Outlet4
      - switch.Tower_PDU_Outlet5
      - switch.Tower_PDU_Outlet6
      - switch.Tower_PDU_Outlet7
      - switch.Tower_PDU_Outlet8

 

 

And a view so that the group can have it's own tab

  Tower_view:
    view: yes
    name: "Tower Power"
    entities: group.Tower

 

 

Node-Red MQTT Message

 

Next modification was to have Node-Red MQTT jive with HASS.  HASS expects to turn on and off outlets with the ON and OFF commands in the MQTT message.  Now you can customized this, but why not play nice.  I could modify HASS to send a 1 for ON and a 0 for OFF with the payload commands for ON and OFF.  I chose to have Node-Red flows that talk HASS' lingo.  Here is a sample of each sending a status and receiving a command.

 

Here is receiving the command. This one if for MQTT topic "tower/outlet0008/control", then the OnOffConversion takes the payload and converts it to a 0 or 1 as needed.  Simple, but repetitive in Node-Red.

image

 

And on the status update side:

 

image

 

 

With the OnOffConversion code looking like this.

var state = "OFF"
if (msg.payload == "1")
    state = "ON";
var nMsg = { payload: state };
return nMsg;

  • Sign in to reply

Top Comments

  • jasonwier92
    jasonwier92 over 8 years ago +4
    Workshopshed and DAB , you two rock. I have done another BLOG with your suggestion and encouragement. I assumed it could not be done and I have done it in the past, just thought this time it could not…
  • Workshopshed
    Workshopshed over 8 years ago +2
    If you find yourself using the same function repeatedly you should be able to put that into a separate flow then included that several times in your main flow. I did something similar to abstract a motor…
  • DAB
    DAB over 8 years ago +1
    Nice update. I agree with Andy. Any good program will group like functions into a single package. Much easier to maintain and change. DAB
  • jasonwier92
    jasonwier92 over 8 years ago

    Workshopshed and DAB, you two rock.  I have done another BLOG with your suggestion and encouragement.  I assumed it could not be done and I have done it in the past, just thought this time it could not be done.  I love you guys! image

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 8 years ago

    Nice update.

     

    I agree with Andy.  Any good program will group like functions into a single package.  Much easier to maintain and change.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago

    If you find yourself using the same function repeatedly you should be able to put that into a separate flow then included that several times in your main flow.

     

    I did something similar to abstract a motor controller Controlling motors and lights with Node-Red

     

    image

    • Cancel
    • Vote Up +2 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