So I’m working on automating the watering of my greenhouse and I’m using ESPEasy on a nodemcu dev board connected to mosquitto. I’ve managed to add 4 buttons configured like this:
switch:
Here is how I would proceed, (not saying that it is the best solution or the most elegent one, tough)
First of all, I would defined an input boolean to decide if you should water that day or not (when you water your plants, that boolean is set ‘off’ for instance)
I would use a script for the watering process, like that
- alias: 'Time to water beds'
trigger:
- platform: time
at: '19:00
condition:
- condition: state
entity_id: yourinputboolean
state: 'off'
for:
hours: 47
action:
- service: input_boolean.turn_on
entity_id: yourboolean
- service : script.turn_on
entity_id: script.waterplants
That’s one solution that should work without too much trouble (note that there is almost certainly mistakes in the code hereabove, do not try to simply copy/paste). There is probably a most elegent one, using appdeamon or something, but I am not used to this add-on.
as you are using a node mcu in your greenhouse, you may also use a humidity sensor (xiaomi flora sensor?) for plant beds, and water your plants exactly when the need it. It should be rather easy, cheap and make you lower the water consumption
2017-06-05 11:00:27 ERROR (MainThread) [homeassistant.config] Invalid config for [script]: [delay] is an invalid option for [script]. Check: script->script->water_greenhouse->sequence->0->delay. (See /home/hass/.homeassistant/configuration.yaml, line 112). Please check the docs at https://home-assistant.io/components/script/
2017-06-05 11:00:27 ERROR (MainThread) [homeassistant.setup] Setup failed for script: Invalid config.
```
Thanks for the tip about xiaomi flora to, have been thinking about that but what I understand they degrade pretty fast so I'm holding off on that for a while!
Sweet, thanks @Bob_NL now I just have one last error:
2017-06-05 13:28:12 ERROR (MainThread) [homeassistant.config] Invalid config for [script]: Entity ID yourinputbool is an invalid entity id for dictionary value @ data['script']['water_greenhouse']['sequence'][12]['entity_id']. Got 'yourinputbool'. (See /home/hass/.homeassistant/configuration.yaml, line 112). Please check the docs at https://home-assistant.io/components/script/
2017-06-05 13:28:12 ERROR (MainThread) [homeassistant.setup] Setup failed for script: Invalid config.
should I change “yourinoutbool” to water_greenhouse as I declared it at the start instead? I’m not sure what @lambtho ment with that part but this is my first script!
You have to define an input boolean first to be able to use it in your script.
The most logical will be to name it water_greenhouse indeed. In that case, implement like this:
input_boolean:
water_greenhouse:
name: Watering Greenhouse
initial: on
change this:
- alias: 'Input bool to off'
service: state.turn_off
entity_id: input_boolean.water_greenhouse
If you use this, the script will be switched off at the end of the sequence. Remember that you’ll have to define a seperate automation which enables the script again in 2 days.
But I see you combined the input boolean and the script, that doesn’t work.
Use the script like you did before and configure the input boolean seperate. Like this:
Input boolean:
input_boolean:
water_greenhouse:
name: Watering Greenhouse
initial: off
input_boolean:
water_greenhouse:
name: Watering Greenhouse
initial: on
icon: mdi:water-pump
but then I get a new error message:
2017-06-05 13:58:11 ERROR (MainThread) [homeassistant.config] Invalid config for [script]: Entity ID input.boolean.water_greenhouse is an invalid entity id for dictionary value @ data['script']['water_greenhouse']['sequence'][12]['entity_id']. Got 'input.boolean.water_greenhouse'. (See /home/hass/.homeassistant/configuration.yaml, line 112). Please check the docs at https://home-assistant.io/components/script/
2017-06-05 13:58:11 ERROR (MainThread) [homeassistant.setup] Setup failed for script: Invalid config.
Looking at the error message I can’t see any difference in what it gets from the script and what I’ve used in the configuration.yaml file?
Woho, now the script isnt throwing me any more errors but I’m still getting some from the automation:
2017-06-05 15:33:40 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID water_greenhouse is an invalid entity id for dictionary value @ data['action'][0]['entity_id']. Got None. (See /home/hass/.homeassistant/configuration.yaml, line 110). Please check the docs at https://home-assistant.io/components/automation/
I added a water sensor to the tank that feeds the self watering plants, and it is very effective. I’m happy to provide more information on my project if you are interested, but I realise it’s a totally different direction for you
@Naesstrom sorry for having provided an incomplete solution in my first post. I tought you were kinda familiar with automations and HASS,… if I knew that it was your first automation I would have paid more attention and make sure that it was a working solution first…
Hope you finally make it work with the help of the others…
For me, the best way was trial and error! And be very active on the community in both reading and discussing. There isn’t a all-in-1 tutorial or something like that, it just doesn’t work that way in my opinion.
YES! Thanks everyone for helping me through it! No errors and it shows up with the automations now!
I’ve tried reading the examples first and got some automations working before but never dared to venture into scripts!
One last thing, can I make a switch that calls the script somehow if I manually want to start the watering?
Finishing up the last of the wiring and making sure the connections are tight, then I’ll take some photos and write up something on how it’s working!
If you put the script on a card using groups, it will appear with a toggle switch. Toggling right activates the script.
Then, if you want it as a button, in customize put:
script.water_greenhouse:
can_cancel: false
And the toggle will be replaced with a ‘button’ saying Activate. Pressing Activate will manually run the script. Beware though that if you want to cancel the script halfway through the toggle might be better, otherwise you will have to manually call the stop script command to cancel midway through. Depends on your use case.