Home Assistant Community

BRUH DIY Multisensor

#407

so I tried the code you gave me, here is mine:

- alias: Temperature above 18 degrees celsius turn on Kitchen Lights
 trigger:
   platform: template
   value_template: >
        {% if states.sensor.sn1_real_feel > 18 %}
             true
        {% endif %}
   action:
   service: switch.turn_on
   entity_id:
    - switch.kitchen_lights

I get errors:

2017-07-30 17:07:44 ERROR (Thread-2) [homeassistant.util.yaml] while parsing a block mapping
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 1, column 1
expected <block end>, but found '<block mapping start>'
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 451, column 2
2017-07-30 17:07:44 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 1, column 1
expected <block end>, but found '<block mapping start>'
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 451, column 2
0 Likes

#408

Align your spaces :wink: looks like you need to add about 2 more spaces to each line at the begining

1 Like

#409

right so I got it working but I have the same issues as earlier i.e. it doesn’t work when the temperature goes above 18 degrees celsius because at present the temperature is above 19.5 and it doesn’t seem to turn the Kitchen Lights on.

and here is my code:

- alias: Temperature above 18 degrees celsius turn on Kitchen Lights
  trigger:
    platform: template
    value_template: >
         {% if states.sensor.sn1_real_feel > 18 %}
              true
         {% endif %}
  action:
   service: switch.turn_on
   entity_id:
    - switch.kitchen_lights

any idea?

0 Likes

#410

The template is wrong, it shoud be

{% if states.sensor.sn1_real_feel.state | float > 18 %}
  true
{% endif %}

Note that the ’ | float ’ is only necessary if your sensor send data as a string and not as a numeric (which is the case using Ben’s code I think).

Note also that there is a template utility in development tools on the frontend. You can type in your template in this utility and directly see the result, so you can mess around freely and change it to suit your needs. Here is a screenshot of the test I just did

However, I think that using this automation like that, your fan will always be turning on as soon as long as the temp is > 18; even at night, even when no one is home. So you may want to put some conditions to limit it and save some money on the electricity bill. :wink:

2 Likes

#411

nice, I was looking for something similar ! I will definitely check that next week !

0 Likes

#412

does your template action straight away i.e. if the temperature is greater than 18, would it turn the e.g. lights right away? because like @SeveredDime mentioned:

it’s because the automation doesn’t technically trigger because the temp is already above the set point when you started. The temp didn’t go from 17.9 to 18.0. so it doesn’t fire.

0 Likes

#413

Oops missed the last attribute :stuck_out_tongue:

It’ll throw a true so as long as your conditions are met it should technically turn on as soon as it’s over 18, even if the sensor starts at 19.

0 Likes

#414

The template trigger will always be true as long as the temp is above 18 (even if it is already above 18 when you restart HASS). Meaning that if for some reason you manually turn off the switch, the automation will directly turn it on if the temp is still > 18. (which may be annoying).

That is the difference with numeric_state above 18. In that second case, the trigger will turn true when the temp goes from under 18 to 18 or more. So it triggers only when the threshold is crossed.

0 Likes

#415

nope its a shame the temperature is 18.2 now and the template trigger is not true it seems, here is my code:

- alias: Temperature above 18 degrees celsius turn on Kitchen Lights
  trigger:
    platform: template
    value_template: >
         {% if states.sensor.sn1_real_feel.state | float > 18 %}
           true
         {% endif %}
  action:
   service: switch.turn_on
   entity_id:
    - switch.kitchen_lights
0 Likes

#416

here is my working automation:

# turn on ac if temp is 30 or above 30 
  - alias: 'AC on If Temp >= 30'
    initial_state: True
    trigger:
      - platform: template
        value_template: '{{ states.sensor.sn1_temperature.state | float >= 30}}'
    action:
      service: switch.turn_on
      entity_id: switch.ac
3 Likes

#417

Awesome, the people smarter than me showed a better way :slight_smile: I’ll be changing my automation.

1 Like

#418

are you using BRUH’s DIY Multisensor to sense the temperature?

also could you elaborate on “initial_state: True” sorry I am a noob.

Does your automation fire everytime the temperature is above 30? The code you provided does work for me but once 5mins after I restart HA.

Is yours the same?

0 Likes

#419

Yes, I am using BRUH’s Multisensor.

As of version 0.42 you have to set an initial state in your automations in order for Home Assistant to restore them upon restart.

I have 2 automation:

  1. when temp is 30 turn on ac and turn off fan.
  2. when temp is 24 turn on fan and turn off ac

and its working fine.

I am also a noob, the automation code provided by @lambtho

Thanks again @lambtho

2 Likes

#420

I received MQ-135 sensor today and uploaded your sketch successfully but it showing airquality value “705.52” all the time.

0 Likes

#421

I had wrong values with MQ-2 sensor plugged to the PC everything was solved when I plugged into the wall instead.

0 Likes

#422

but in my case value is fixed 705.52 no up and down even I have plugged with a wall adapter.

0 Likes

#423

It’s been recommended to leave the sensor on for 24 hours to allow it to ‘burn-in’.

0 Likes

#424

okay, will do that and let you know about result.

Thanks

0 Likes

#425

I tried contacting him to get his yaml files for HASS but I wasn’t able to find his contact info. It looks a lot cleaner.

It looks like the data comes out like this:

homeassistant/sensor/sensornode3_sensor_temp/state 79.16
homeassistant/sensor/sensornode3_sensor_humidity/state 41.70
homeassistant/binary_sensor/sensornode3_sensor_pir/state OFF

0 Likes

#426

Yes, that is what I understood from looking upon the code… Seems nice

0 Likes