Quick check of my watering automation - will it work?

Hi guys,

I need some help. I created an automation for my gardena watering. I want to water the garden only when it did not rain (not more than 0.259l).
I am unsure about the way I entered the condition. Do I need to use “,” or “.” and does it work with the key “<” to indicate the rain amount.
Unfortunately I cannot test it easily, because rain sensor is on the roof :slight_smile:

- id: '1656760454216'
  alias: Bewässerung An
  description: ''
  trigger:
  - platform: time
    at: '18:00:00'
  condition:
  - condition: state
    entity_id: sensor.regen_tag
    attribute: state_class
    state: < 0,259
  action:
  - service: switch.toggle
    data: {}
    target:
      entity_id: switch.water_control_50914
  mode: single
- id: '1656760734324'
  alias: Bewässerung Aus
  description: ''
  trigger:
  - platform: time
    at: '19:00:00'
  condition: []
  action:
  - service: switch.toggle
    data: {}
    target:
      entity_id: switch.water_control_50914
  mode: single

Help is very much apreaceated.
Thanks upfront

It’s really hard to tell since you didn’t properly format the code block.

use three backticks (```) on the line both before and after the block of code to properly format it.

then we can go from there.

The YAML code you posted is unformatted which makes it difficult for anyone to inspect it for indentation errors. Please format it using the forum editor’s </> icon.

Sorry guys, I am learning. Is that better now?

OK, I am just unsure about that line:

    state: < 0,259

Change this:

  - condition: state
    entity_id: sensor.regen_tag
    attribute: state_class
    state: < 0,259

to this:

  - condition: numeric_state
    entity_id: sensor.regen_tag
    below: 0.259

Numeric State Condition

Many thanks!

OK, unfortunately this didnt work. Log says that the condition wasnt met, although I had no rain today.
What puzzles me is rhe fact, that the rain amout has a comma, like 0,258, but today it was zero.
The rain amount comes from a utility meter, not shure whether this has something to say.

You could also do this in Node Red which some people find easier to visualize what is happening with your code.

Where does it have a comma?
What is creating this sensor?

Go to Developer Tools → States and find sensor.regen_tag. Let us know if its value uses a period or a comma for displaying the decimal point.

If the value is zero then you probably won’t be able to answer the question because it won’t have a decimal point.

If the sensor’s value was zero then it should have satisfied the Numeric State Condition because zero is less than 0.259. :thinking:

I checked the sensor value. Indeed the sensor value has a decimal point. It seems due to language setting it is just displayed with comma.
Anyhow, even stranger that condition was not met. Just time works fine.

Sensor is a utilitymeter based on a rainmeter (gives only total amount)

state_class: total_increasing
source: sensor.aterm3rm
status: collecting
last_period: '0'
meter_period: daily
cron pattern: 0 0 * * *
last_reset: '2022-07-02T22:00:00.013969+00:00'
unit_of_measurement: mm
icon: mdi:counter
friendly_name: Regen_Tag

When I enter the condition in the following way it works:

condition: numeric_state
entity_id: sensor.regen_tag
below: '0.259'

For the Numeric State Condition, there no difference between this:

below: 0.259

and this:

below: '0.259'
  • The first one represents the value as a floating point number.
  • The second represents it as a string which gets converted to a floating point number.

The main point is that your original version using a State Condition and this:

    attribute: state_class
    state: < 0,259

was completely invalid because the state option doesn’t support mathematical operators and you specified an attribute option which made the State Condition refer to the wrong value.