Home Assistant Community

Create "sensor" from two existing ones

#16

Oh yes, your are right, it’s the same with Wunderground. Go to the /dev-state path of your HA installation to identify the available sensors.

0 Likes

#17

Im really curious if @rkarlsba made it work since i want the chill effect as well :slight_smile:
Now im using an sensor from Wunderground but it would be nice to avoid relying on other services when i hav my own sensors :slight_smile:

0 Likes

#18

I must be doing something wrong…

{{ states.sensor.yr.precipitation.state }}

Error rendering template: UndefinedError: ‘None’ has no attribute ‘precipitation’

For loop example:
{% for state in states.sensor -%}
{%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}
{{ state.name | lower }} is {{state.state_with_unit}}
{%- endfor %}.

For loop example:
The cpu temperature is 46.54 °C, the hygrometer på pi is 23.8 %, the termometer på pi is 29.4 °C, the windchill is unknown, the yr humidity is 80.0 %, the yr precipitation is 0.0 mm, the yr pressure is 1009.2 hPa, the yr symbol is 2, the yr temperature is -2.2 °C and the yr wind speed is 0.7 m/s.

0 Likes

#19

Just like @m0wlheld mentioned, you should address an attribute. This should be

{{ states.sensor.yr.attributes.precipitation }}

if precipitation is an attribute to the yr sensor or

{{ states.sensor.yr_precipitation.state }}

if it is a sensor by itself

0 Likes

#20

But I was wrong … the Wunderground weather hub (and yr probably too) create a series of sensors. You need to find them and get their state.

0 Likes

#21

Yes here are some of the sensors YR creates.

And as mentioned earlier sensor.weather_temperature and sensor.weather_wind_speed is the ones @rkarlsba is looking for

image

0 Likes

#22

Well, what’s wrong with this?

  • platform: template
    sensors:
    windchill:
    value_template: >-
    "{{ (13.12 + (0.6215 * sensor.weather_temperature)) - (11.37 * (sensor.wind_speed * 3.6) ** 0.16 + (0.3965 * sensor.weather_temperature) ** 0.16) | float }}"
0 Likes

#23

Every sensor you use must be “states.(entit_id).state | float”, e.g. “states.sensor.weather.temperature.state | float”

Doing so however returns a result below zero, so I guess there’s an error in the formula as well.

0 Likes

#24

{{ states.yr.weather_temperature.state | float }}
{{ states.sensor.weather_temperature.state | float }}

Both give me ‘Error rendering template: UndefinedError: ‘None’ has no attribute ‘state’’

0 Likes

#25

…and

For loop example:
{% for state in states.sensor -%}
{%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}
{{ state.name | lower }} is {{state.state_with_unit}}
{%- endfor %}.

Says

For loop example:
The cpu temperature is 44.39 °C, the hygrometer på pi is 21.1 %, the termometer på pi is 27.0 °C, the windchill is unknown, the yr humidity is 84.5 %, the yr precipitation is 0.3 mm, the yr pressure is 1007.2 hPa, the yr symbol is 13, the yr temperature is -2.1 °C and the yr wind speed is 3.7 m/s.

And then
{{ states.sensor.weather_temperature | float }}

Tells me 0.0

0 Likes

#26

Here is a thread about humidity and temp to calculate chill effect Heat Index / Apparent Temperature / Feels Like Temperature

Here is a link that describes both humid chill index and wind chill index http://www.physlink.com/Reference/Weather.cfm

Here is another one with only wind chill index where you can specify units depending on what sensor you are using http://www.calculator.net/wind-chill-calculator.html

0 Likes

#27

Please follow the examples closely before posting.

{{ states.sensor.weather_temperature.state | float }}

It looks like you’re just trying stuff you don’t fully understand. It might be wise to read some of the documentation first.

1 Like

#28

This is based on humidity and temperature from YR

  - platform: template
    sensors:
      chill_index:
        value_template: '{{ (((((((states.sensor.weather_temperature.state|float)*1.8)+32) + 61.0 + (((((states.sensor.weather_temperature.state|float)*1.8)+32)-68.0)*1.2) + ((states.sensor.weather_humidity.state|float)*0.094))*0.5)-32)/1.8)|round(1) }}'
0 Likes

#29

Thanks, but… Technically, it works, but AFAICS the formula is wrong. Compared it with yr, and what’s on their website shows a far lower windchill than this, that is, measured in celsius

Edit: That is, it’s said to be an index - does that mean it should be added to the temperature?

0 Likes

#30

check this:

0 Likes

#31

@Mariusthvdb when i tried your sensors i get error:

“Could not render template Jag/Ti Wchill, the state is unknown.”

0 Likes

#32

doing their job here:

37

maybe you didnt define the sensors this template sensor uses? I use platform Buienradar https://home-assistant.io/components/weather.buienradar/

1 Like

#33

I had missed one character :stuck_out_tongue:

Now i have both on humidity and wind based on different formulas and a average based on them.

image

0 Likes

#34

Looking good!

Could you please share your code?

0 Likes

#35

Here it is. Using both sensors from YR.no, other sensors and code from @Mariusthvdb Mariusthvdb

  - platform: template
    sensors:
      heat_index_1:
        unit_of_measurement: '°C'
        value_template: '{{ (((((((states.sensor.weather_temperature.state|float)*1.8)+32) + 61.0 + (((((states.sensor.weather_temperature.state|float)*1.8)+32)-68.0)*1.2) + ((states.sensor.weather_humidity.state|float)*0.094))*0.5)-32)/1.8)|round(1) }}'
      jagti_windchill:
        value_template: '{{ (13.12 + 0.6215*float(states.sensor.weather_temperature.state) + 0.3965*(float(states.sensor.weather_temperature.state) - 28.676) *(float(states.sensor.weather_wind_speed .state)*3.6)**0.16) | round(2) }}'
        unit_of_measurement: '°C'
        friendly_name: Jag/Ti Wchill
# Tchill(°C) = 13,12 + 0,6215*Tair + 0.3965*(Tair - 28,676)*S10m0,16
# S10m = windspeed (km/h) at anemometer_height = 10 m, Tair in °C
      jagti_windchill_2:
        value_template: '{{(13.12 +0.6215*float(states.sensor.weather_temperature.state) -11.37*(float(states.sensor.weather_wind_speed.state)*3.6)**0.16 +0.3965*float(states.sensor.weather_temperature.state)*(float(states.sensor.weather_wind_speed.state)*3.6)**0.16) | round(2) }}'
        unit_of_measurement: '°C'
        friendly_name: Jag/Ti Wchill v2
#G  =13,12+0,6215*T-11,37*(W*3,6)^0,16+0,3965*T*(W*3,6)^0,16
#Invoerveld T = Temperatuur in Graden Celsius
#Invoerveld W = Wind in meter / seconde
      steadman_windchill:
        value_template: '{{ (1.41 - 1.162*float(states.sensor.weather_wind_speed.state) + 0.98*float(states.sensor.weather_temperature.state) + 0.124*float(states.sensor.weather_wind_speed.state)**2 +0.0185*float(states.sensor.weather_wind_speed.state)*float(states.sensor.weather_temperature.state)) | round(2) }}'
        unit_of_measurement: '°C'
        friendly_name: Steadman Wchill
# Tchill(°C) = 1.41 - 1.162*S + 0.98*Tair+0.0124*S2 + 0.0185*S*Tair
# Tair in °C en S= in m/s.
  - platform: min_max
    name: 'Medel_chill_effect'
    type: mean
    entity_ids:
      - sensor.heat_index_1
      - sensor.jagti_windchill
      - sensor.jagti_windchill_2
      - sensor.steadman_windchill
      - sensor.pws_feelslike_c
  - platform: min_max
    name: 'Medel_temp_ute'
    type: mean
    entity_ids:
      - sensor.weather_temperature
      - sensor.pws_temp_c
      - sensor.net_utomhus_temperature
1 Like