Automation with pump water and two tanks

Dear,

I’m doing an automation for triggering tank1000’s pump in situations:

  • When the Tank3000 runs out of water and the
    • “sensor up” on and
    • “sensor down” on
      and
  • Tank1000 is with
    • “sensor down” off

action

  • Turn on the “tank1000 relay” to refill the tank.

case

  • tank1000 is with the “sensor down” on
    action
    turns off the “tank1000 relay”.

follows code:

alias: "Tank water pump - on"
id: tank001
trigger:
   - platform: mqtt
     topic: 'stat / tank3000 / POWER2'
     payload: 'ON'
condition:
   condition: and
   conditions:
     - condition: state
       entity_id: switch.tank3000_sensor_up
       state: 'ON'
     - condition: state
       entity_id: switch.tank1000_sensor_down
       state: 'OFF'
action:
   service: switch.turn_on
   entity_id: switch.tank1000_relay

configuration of tanks:

tank1000

  • Toggle1 = relay
  • Toggle2 = sensor up
  • Toggle3 = sensor down

Sensors:
toggle2 e toggle3
off = tank with water
on = tank without water

tank3000

  • Toggle1 = sensor up
  • Toggle2 = sensor down

Sensors:
toggle1 e toggle2
off = tank with water
on = tank without water

What exactly is your question? I’m not sure what it is that you’re after…

My automation is not working.
I wonder what’s wrong!

Thank you

I don’t think you can have spaces in your topic.

Thank you,

was check in the code and does not have this space, it was a small typo.Thank you,

was check in the code and does not have this space, it was a small typo.

‘stat/tank3000/POWER2’

check inthe state table that your state and topic payload are actually “ON” and not “on” etc.

“ctrl +c” and “ctrl +v”

alias: "Tank water pump - on"
id: tank001
trigger:
  - platform: mqtt
    topic: 'stat/tank3000/POWER2'
    payload: 'ON' 
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: switch.tank3000_sensor_up
      state: 'ON'
    - condition: state
      entity_id: switch.tank1000_sensor_down
      state: 'OFF'
action: 
  service: switch.turn_on
  entity_id: switch.tank1000_relay  

Checked !! OK !!

Are your sensors switches or sensors? and are the names correct as stated in the switches/sensors part of the state table?

Yes they are.
The sensors are reed switch.
All the names are declared correctly and I simulate the states.

image

How do you do this?

Actuating the sensors!

- condition: state 
  entity_id: switch.tank3000_sensor_up 
  state: 'ON' 
- condition: state 
  entity_id: switch.tank1000_sensor_down 
  state: 'OFF'

I suspect the reason it isn’t triggering is that the states need to be ‘on’ and ‘off’.

If you look in the states table, you will find the only things that are uppercase are any input_selects that you have defined as uppercase. At least that’s the case in mine :wink:

Keithh66,

I will describe my simulation scenario:

tank3000


image

###### Tank3000    
  - platform: mqtt
    name: "tank3000 sensor up"
    state_topic: "stat/tank3000/POWER1"
    command_topic: "cmnd/tank3000/POWER1"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true    
  - platform: mqtt
    name: "tank3000 sensor down'"
    state_topic: "stat/tank3000/POWER2"
    command_topic: "cmnd/tank3000/POWER2"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true        

####################
tank1000


image

###### Tank1000
  - platform: mqtt
    name: "tank1000 relay"
    state_topic: "stat/tank1000/POWER1"
    command_topic: "cmnd/tank1000/POWER1"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
  - platform: mqtt
    name: "tank1000 sensor up"
    state_topic: "stat/tank1000/POWER2"
    command_topic: "cmnd/tank1000/POWER2"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
  - platform: mqtt
    name: "tank1000 sensor down"
    state_topic: "stat/tank1000/POWER3"
    command_topic: "cmnd/tank1000/POWER3"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

In this situation I would like automation to trigger relay tank1000:

image

In this situation I would like the automation to work!
As you can see, the relay was not activated.
image

What I would like automation to do would be:
image

but unfortunately it does not happen !:
image

here is the automation code:

alias: "Tank water pump - on"
id: tank001
trigger:
  - platform: mqtt
    topic: 'stat/tank3000/POWER2'
    payload: 'ON' 
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: switch.tank3000_sensor_up
      state: 'ON'
    - condition: state
      entity_id: switch.tank1000_sensor_down
      state: 'OFF'
action: 
  service: switch.turn_on
  data:
    entity_id: switch.tank1000_relay  

I found the error:

had a ’
in:

     name: "tank3000 sensor down'"

for

     name: "tank3000 sensor down"

Thank you for your help !!

Glad you got it working :smile: , next time post all of the config not just what you think is not working :stuck_out_tongue: