Home Assistant : Q&A, Tips & Tricks, Your Configs

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
9,884
Please excuse my ignorance, but with what are you doing all of this? What's your setup look like?
I have a mix of Xiaomi temp/humidity sensors and also Sonoff temp/humidity/door/windows and a select few other zigbee sensors on a Sonoff zigbee hub.

Zigbee devices

The outside temp sensor is a bit of a challenge. You need to place it somewhere, where there is no direct sunlight on it, but also it shouldn't be above concrete/stone/etc where the sun bakes that hot and then cause above normal high readings during the day on the sensor. I suspect mine is in a good place, there is ever so slightly some sun in the morning but then rest of day only shade and nothing is baked hot in the sun around it.
 

ebendl

Expert Member
Joined
Sep 27, 2004
Messages
4,175
One of my latest additions is adding a "feels like" for outside temperature, based on a complex formula and then adding a 'custom:mini-graph-card' with color thresholds to show what the temperature feels like in rainbow colors.

This is what it looks like, bottom left.
View attachment 992664

I have my graph card combined with the weather-forecast card, so in code it looks like this:
Code:
cards:
  - entity: weather.home
    type: weather-forecast
  - break
  - entities:
      - sensor.heat_index
    icon: 'mdi:thermometer'
    legend: true
    name: Outside temperature feels like
    show:
      extrema: true
      icon: true
    type: 'custom:mini-graph-card'
    points_per_hour: 2
    color_thresholds:
      - value: 37
        color: '#7e0001'
      - value: 35
        color: '#9a0000'
      - value: 32
        color: '#d80100'
      - value: 29
        color: '#fe0000'
      - value: 26
        color: '#f46523'
      - value: 24
        color: '#ff9e07'
      - value: 21
        color: '#ffd728'
      - value: 18
        color: '#ffff01'
      - value: 15
        color: '#cdff00'
      - value: 13
        color: '#80ff00'
      - value: 10
        color: '#3ab54a'
      - value: 7
        color: '#05f7f8'
      - value: 4
        color: '#00ccff'
      - value: 2
        color: '#017eff'
      - value: -1
        color: '#0000fe'
      - value: -4
        color: '#1b1464'
      - value: -7
        color: '#662e93'
layout: vertical
min_columns: 1
type: 'custom:layout-card'

and my feels_like.yaml package:
Code:
sensor:
  #Heat index
  - platform: template
    sensors:
      heat_index:
        friendly_name: 'Outside Feels Like'
        #formula taken from http://www.srh.noaa.gov/ama/?n=heatindex
        value_template: >-
          {%- set outside_f = ((states('sensor.outside_temperature')|float * 1.8000)+32.00) -%}
          {% if 112 > outside_f | float > 80 and states('sensor.outside_humidity') | float < 13 %}
            {% set value = (((-42.379 + (2.04901523*(outside_f|float)) + (10.14333127*(states.sensor.outside_humidity.state|float)) - (0.22475541*(outside_f|float)*(states.sensor.outside_humidity.state|float)) - (0.00683783*(outside_f|float)*(outside_f|float)) - (0.05481717*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) + (0.00122874*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)) + (0.00085282*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) - (0.00000199*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)))-(((13-(states.sensor.outside_humidity.state|float))/4)*sqrt((17-(((outside_f|float)-95)|abs))/17))) | round(3)) %}
          {% elif 87 > outside_f | float > 80 and states('sensor.outside_humidity') | float > 85 %}
            {% set value = (((-42.379 + (2.04901523*(outside_f|float)) + (10.14333127*(states.sensor.outside_humidity.state|float)) - (0.22475541*(outside_f|float)*(states.sensor.outside_humidity.state|float)) - (0.00683783*(outside_f|float)*(outside_f|float)) - (0.05481717*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) + (0.00122874*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)) + (0.00085282*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) - (0.00000199*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)))-(((states.sensor.outside_humidity.state|float)-85)/10)*((87-(outside_f|float))/5)) | round(3)) %}
          {% elif outside_f | float < 80 %}
            {% set value = ((0.5*((outside_f|float) + 61.0 + (((outside_f|float)-68)*1.2) + ((states.sensor.outside_humidity.state|float)*0.094))) | round(3)) %}
          {% else %}
            {% set value = ((-42.379 + (2.04901523*(outside_f|float)) + (10.14333127*(states.sensor.outside_humidity.state|float)) - (0.22475541*(outside_f|float)*(states.sensor.outside_humidity.state|float)) - (0.00683783*(outside_f|float)*(outside_f|float)) - (0.05481717*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) + (0.00122874*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)) + (0.00085282*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) - (0.00000199*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)))| round(3)) %}
          {% endif %}
          {{ ((value - 32)/1.8000|float) | round(3) }}
        unit_of_measurement: '°C'
Very cool, thanks. I can't seem to access http://www.srh.noaa.gov/ama/?n=heatindex - get a server not found issue.

Basically convert ourside temperature to Fahrenheit, then combine using humidity and temperature and their formula, then convert it back to Celcius?

Do you need to format everything as floats the whole time - the (outside_f|float) pieces?
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
9,884
Very cool, thanks. I can't seem to access http://www.srh.noaa.gov/ama/?n=heatindex - get a server not found issue.

Basically convert ourside temperature to Fahrenheit, then combine using humidity and temperature and their formula, then convert it back to Celcius?

Do you need to format everything as floats the whole time - the (outside_f|float) pieces?
Without the float the round to 3 decimals don't work. Then you sometimes get a value of 21.34638888888 and that looks terrible in love lace.
Also prevent random errors in the logs.
 

ebendl

Expert Member
Joined
Sep 27, 2004
Messages
4,175
I have a mix of Xiaomi temp/humidity sensors and also Sonoff temp/humidity/door/windows and a select few other zigbee sensors on a Sonoff zigbee hub.

Zigbee devices

The outside temp sensor is a bit of a challenge. You need to place it somewhere, where there is no direct sunlight on it, but also it shouldn't be above concrete/stone/etc where the sun bakes that hot and then cause above normal high readings during the day on the sensor. I suspect mine is in a good place, there is ever so slightly some sun in the morning but then rest of day only shade and nothing is baked hot in the sun around it.
I have a bridge sitting here that I haven't opened up yet. Still using my Aqara hubs, no idea when I'll switch over :( Are you using the ZHA & tasmota combo?

And my outside temperature sensor (also an Aqara) is exactly where it shouldn't be - above the paving that surrounds my house. Also need to place it out of the way of rain which is part of the problem.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
9,884
I have a bridge sitting here that I haven't opened up yet. Still using my Aqara hubs, no idea when I'll switch over :( Are you using the ZHA & tasmota combo?
Initially I used ZHA mode with tasmota...but I hate the random sensor names that home assistant came up with in this mode. Its very nice for the novice, but I decided to do it the hard way and use it in Tasmota mode with mqtt. So technically zigbee2tasmota or something like that mode.

Created a bunch of automation rules to automatically create sensors for me. See: https://github.com/tinuva/home-assistant-config/blob/master/packages/tasmota_zigbee.yaml
This basically automatically creates all sensors for me, as soon as I give it a name on the hub. With names based on the name I gave it in the hub.
The only devices I dont have and have not tested, is zigbee lights. Especially if they support colors.

The only thing you still need to do manual after that, is if you have buttons. You can just shoot events for that like I do in https://github.com/tinuva/home-assistant-config/blob/master/packages/tasmota_zigbee_action.yaml
 

Veroland

Executive Member
Joined
Aug 24, 2005
Messages
5,946
I know it's been discussed but I can't find it.
I have the following camera https://www.ezvizlife.com/product/C3W/581

The rstp stream in HA has about a 10 sec delay but through the EZVIZ app it is only a second or so. Both running in the LAN.

Did anyone find a way to get a more up to date stream in HA?
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
9,884
I know it's been discussed but I can't find it.
I have the following camera https://www.ezvizlife.com/product/C3W/581

The rstp stream in HA has about a 10 sec delay but through the EZVIZ app it is only a second or so. Both running in the LAN.

Did anyone find a way to get a more up to date stream in HA?
have you viewed the rtsp stream in VLC? Does it still have the 10 second lag?

As far as I know, there is no lag on the rtsp stream, but rather its added by HA because of how it proxy/buffer the stream. Its great when multiple devices read the stream from HA, as it still only reads 1 stream from the camera.
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
3,157
I know it's been discussed but I can't find it.
I have the following camera https://www.ezvizlife.com/product/C3W/581

The rstp stream in HA has about a 10 sec delay but through the EZVIZ app it is only a second or so. Both running in the LAN.

Did anyone find a way to get a more up to date stream in HA?
I have had the same problem with the Sonoff camera. I had it in HA with the FFMPEG stream had about 7 seconds delay. Added it to Blue Iris, and now I am pulling the BI stream into HA with the MJPG stream and there is no delay from the BI feed or the Ewelink app.
 

Veroland

Executive Member
Joined
Aug 24, 2005
Messages
5,946
have you viewed the rtsp stream in VLC? Does it still have the 10 second lag?

As far as I know, there is no lag on the rtsp stream, but rather its added by HA because of how it proxy/buffer the stream. Its great when multiple devices read the stream from HA, as it still only reads 1 stream from the camera.
Awsome idea

In VLC there is less than sec between VLC and the EZVIZ app!
Thanks a lot!
 

Veroland

Executive Member
Joined
Aug 24, 2005
Messages
5,946
I have had the same problem with the Sonoff camera. I had it in HA with the FFMPEG stream had about 7 seconds delay. Added it to Blue Iris, and now I am pulling the BI stream into HA with the MJPG stream and there is no delay from the BI feed or the Ewelink app.
As what type of camera did you add it to BI?

I added mine to motionEye as RSTP and have about a 5 sec delay there.
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
3,157
As what type of camera did you add it to BI?

I added mine to motionEye as RSTP and have about a 5 sec delay there.
Make is Generic/ONVIF, but then using the RTSP stream for the model. I also added it to MotionEye previously to try and get a smaller delay, using the rtsp stream directly from the camera. This also seems to be in sync with the BI feed now.
 

Veroland

Executive Member
Joined
Aug 24, 2005
Messages
5,946
Make is Generic/ONVIF, but then using the RTSP stream for the model. I also added it to MotionEye previously to try and get a smaller delay, using the rtsp stream directly from the camera. This also seems to be in sync with the BI feed now.
My motionEye is running as a addon on my PI3 Hassio so it might also be that causing the 5 sec delay.
 

Kobusdb

New Member
Joined
Jan 1, 2021
Messages
5
Hi Tom. Yes I do have a keypad. I have opened and taken a picture of the unit and attached. Issue is that the keypad and the unit is not in the same location. Energizer and ewelink switch is in the garage. Keypad is in the kitchen. Any ideas? I just want to be able to tell if the energizer is on or off from the app. Thats it.
Hi Steamy Tom. Are you able to assist further? would much appreciate
 

calypso

Expert Member
Joined
Feb 10, 2009
Messages
1,653
So does anyone have suburb based load shedding information in home assistant? I would love to be able to run scripts to shut things down just before load shedding starts, but I don't know how.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
9,884
So does anyone have suburb based load shedding information in home assistant? I would love to be able to run scripts to shut things down just before load shedding starts, but I don't know how.
Think a couple of people here use google calender to get it into HA. Ask @xrapidx

I have mine in node-red which then trigger stuff within HA and then I can do the rest from there.
Well I haven't implemented it yet, but the plan is to do it soon. This weekend is as good a time as any, since we have live loadshedding
 

calypso

Expert Member
Joined
Feb 10, 2009
Messages
1,653
Oh wow, I didn't even know about the calendar feature, I can use that for quite a few things. Now to get the status into my google calender will do some digging.
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
38,849
Yip - I have google calendars which I reference in code.

I wrote a SQL script (because I had SQL open) which generates the calendar csv, and them import it into Google.
 

Attachments

  • Screenshot from 2021-01-15 10-19-38.png
    Screenshot from 2021-01-15 10-19-38.png
    64.6 KB · Views: 35

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
9,884
Oh wow, I didn't even know about the calendar feature, I can use that for quite a few things. Now to get the status into my google calender will do some digging.

you will put the slots into the calender, so thats how you will know if you in a slot. So you need to build slots for all the different stages.

The stage you can get from eskom
Code:
~ % curl 'https://loadshedding.eskom.co.za/LoadShedding/GetStatus?_=1610635298203'
3

Although they currently report -1 from a random backend.
You need to take that value and -1 to get the current stage.
 

calypso

Expert Member
Joined
Feb 10, 2009
Messages
1,653
OK this all looks lovely, I just don't know how to do it yet as these are all new concepts to me. Will figure it out this weekend.
 

w1tw0lf

Senior Member
Joined
Sep 29, 2009
Messages
866
I am currently using this one, but only gives the level of loadshedding.

 
Top