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
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog PDU #13 - Automation with Home Assistant - [Upcycle It]
  • 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: 2 Jun 2017 2:44 PM Date Created
  • Views 629 views
  • Likes 6 likes
  • Comments 1 comment
  • upcycle_it
  • home assistant
  • winners
  • upcycled_pdu
Related
Recommended

PDU #13 - Automation with Home Assistant - [Upcycle It]

jasonwier92
jasonwier92
2 Jun 2017

In this BLOG entry I want to share some of my automation that I have planned on getting working with my PDU.  This example is showing one Edison reporting temperature to Home Assistant and then Home Assistant turning on and off an outlet that the fan is plugged into.  Hard to read the temperature on the tablet, but as it climbs to over 80 degrees, it turns on the fan and when to goes back down to under 78 it will turn it off. I am simply using my finger to warm up the temperature sensor to over 80 degrees.

 

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

 

Here is how this is all done. Node-Red reads, converts, and reports the temperature via MQTT and Web Sockets (WS). Then Home Assistant reads and displays this value. Also I have automation setup to turn on and off the fan. Lets break down the parts.

 

Node-red

image

Here you can see the Temperature is being read, then formatted to Celsius and Fahrenheit.  The sent back out.  The conversion looks like this.

 

var retMsg = {};
var a = msg.payload;
var B = 4275;
var R = (1023.0/a - 1.0) * 100000.0;
var tC = 1.0 / (Math.log(R/100000.0) / B + 1 /298.15) - 273.15;
var tF = Math.round((tC * 9 / 5 + 32) * 100) / 100;
retMsg.payload = {
    tempC: Math.round(tC * 100) /100,
    tempF: tF
}


return retMsg;

 

Then I publish to the MQTT channel and the WS.  What goes out is JSON with both values in it.

 

Sensor in Home Assistant (HA)

 

Next I setup the sensor in HA. The tricky part is getting the value out of the object that I want to see. I would setup Fahrenheit for myself, but my Dad would like to see Celsius.  Here is the sensor config:

 

- platform: mqtt
    state_topic: "office/temperature/status"
    name: "Office Temperature"
    qos: 0
    unit_of_measurement: "°F"
    value_template: "{{ value_json.tempF }}"

 

and here is what it looks like in HA:

 

image

Click on it and I see:

 

image

You can see my history of doing tests of the fan.  I have thought about taking ten samples, taking out the high and low and averaging the rest of the values to report a more steady temperature.

 

Automation in HA

 

Here is where the fun starts. Before I setup all eight outlets in HA.  Now I plugged a fan into outlet 1, because when it gets hot in my office, it is nice to have a fan blowing on me. But who wants to think when we have computers to do that for us.  So I setup two automation configurations.  One turns on the fan during working hours if the temperature is reported at over 80 degrees and the fan is off, no since in telling it to turn on when it is on.  The seconds turns off the fan if the fan is on and if the temperature goes below 78 degrees.  On the off automation, there is no time constraint, because I want it to turn off when the room is cool.  I might setup a third automation that turns off the fan after 10PM, because who needs it then and if I do need it, I can turn it on via HA!

 

Here is my ON automation:

::::::::::::::
fan_on.yaml
::::::::::::::
  alias: 'Turn on office fan'
  trigger:
    platform: numeric_state
    entity_id: sensor.office_temperature
    above: 80
  condition:
    condition: and
    conditions:
    - condition: time
      after: '08:00:00'
      before: '17:00:00'
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
    - condition: state
      entity_id: switch.tower_pdu_outlet1
      state: 'off'
  action:
    service: switch.turn_on
    entity_id: switch.tower_pdu_outlet1

 

Here is of OFF automation

::::::::::::::
fan_off.yaml
::::::::::::::
  alias: 'Turn off office fan'
  trigger:
    platform: numeric_state
    entity_id: sensor.office_temperature
    below: 78
  condition:
    condition: state
    entity_id: switch.tower_pdu_outlet1
    state: 'on'
  action:
    service: switch.turn_off
    entity_id: switch.tower_pdu_outlet1

 

 

This was my main objective of the project.  I still would like to do more with the LCD, but my mom's health problems and daughter's graduation, I might have to put some extras on hold for now. Before this would go in my tower, I would see a world where I would replace outlets with terminals or connectors to turn on and off 12V devices.  And if this would stay at my desk, I would picture me making it into a PDU that is also a power supply with USB ports build in and replacing some outlets.  Also using solid state relays for the outlets.  I am having good fun with this project.

  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +1
    Nice update. Yes family comes first. DAB
  • DAB
    DAB over 8 years ago

    Nice update.

     

    Yes family comes first.

     

    DAB

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