Hi all,
this is my first post, most of my problem I could resolve by my own. I used in the past openHab for my automation. But now I moved to HA. And I have now 99 % running. Only one think I must move to HA. Maybe someone have a idea how.
I create a rules (in openHab) to get a message when my dryer is finished. And now I try to create the same with the automation in HA. I use a state machine in my old environemt. But current I habe no idea how to create this in HA.
For example the rule in openhab:
val String filename = "dryermachine.rules"
val Number MODE_OFF = 0
val Number MODE_ACTIVE = 1
val Number MODE_FINISHED = 2
rule "Dryer state: Init"
when
System started
then
if (dryer_OpState == NULL) {
dryer_OpState.postUpdate(MODE_OFF)
logInfo("dryer_OpState state" + dryer_OpState.state)
}
end
rule "Washingmachine state: Power changed"
when
Item hmSteckdose_CE_WASCHKUECHE_POWER changed
then
if (hmSteckdose_CE_WASCHKUECHE_POWER.state > 50) {
dryer_OpState.sendCommand(MODE_ACTIVE)
}
else if (hmSteckdose_CE_WASCHKUECHE_POWER.state > 1.2 && hmSteckdose_CE_WASCHKUECHE_POWER.state < 50) {
dryer_OpState.sendCommand(MODE_FINISHED)
if(now.getHourOfDay() < 21 && now.getHourOfDay() > 8) {
Echo_Kitchen_TTS.sendCommand('Trockner ist fertig!')
}
}
else {
dryer_OpState.sendCommand(MODE_OFF)
}
end
The main idea is, that i measured the power consumption and know when the running programm is finished. The problem was that at the start the power consumption is also the same like at the end. This is why I create the state machine.
Any ideas how to do this in HA automation?
You could for example use input helpers to store information and use them in your Automations.
Or do it in node red, as there are state and statemachine nodes available as well as a Ha integration
How do you mean? Because the dryer always goes to a very low consumption during the program. But never to zero.
And so I always have the same state during operation as at the end of the program.
Not sure if I understand exactly what you need. How do you switch from MODE_FINISHED to MODE_OFF? Which means, how do you see if the dryer is emtpy and ready for the next run?
Maybe the delay_off option of the template binary sensor can help you if you have short âlow powerâ times during a run. Thatâs how I see if the dryer or washing machine is running.
By that, you get the message a few minutes later, but thatâs not a problem for me.
My dryer uses different power in state âfinished but closedâ and âoffâ => by that, I see if itâs finished or off.
The washing machine doesnât have that difference. There I use a magnetic binary sensor (aqara) at the door to see when it gets opened.
Oh⊠maybe I have a error in my old implementation. But it works. I will measure the power when I use it the next time, then I try to implement it in HA.
Thanks for the hints.
I am too new in the hole HA . But what is a binary_sensor ? Is it the part I found -> âBedingte Elementeâ?
My target is to get an Alexa message if the dryer done his work. So, when âwaschmaschine_runningâ is off. But do I not get every time a message if the dryer is off? I want only a message if the âwaschmaschine_runningâ is changing from on to off.
Sorry for asking again.
OK. Im must add my binary sensors in the binary sensors yaml. And then I can use them in the automation. im was searching in the GUI for that. But must change it in the file. Understand
Slightly off topic: There is a third-party integration for HA called Appdaemon that enables you to write automation apps in python. I have implemented a general purpose finite state machine with appdaemon and so have others in this forum. This might be easier then trying to implement a state machine in the somewhat limited HA automation environment. https://appdaemon.readthedocs.io/en/latest/
I would do what @nickrout said and use the power consumption going to 0 (or what ever the lowest value is when finished) for a period of time.
So if the cycles go to the lowest setting of power for (example) no longer than two minutes between the next cycle then set the trigger to:
trigger:
- platform: numeric_state
entity_id: sensor.dryer_power # or whatever the entity_id is for your dryer power monitor in HA
below: 5 # or whatever the expected power level is when done
for:
minutes: 3 # longer than the longest interval between cycles so you know it's done if longer than that
I realise that you are new to HA so my apologies that Iâm now giving you something extra to learn⊠Have a look at Packages as these make organising your code SO much easier. It lets you keep all code related to a particular âthingâ or function in the one file. ie: clothes_dryer.yaml
I have basically what you want for my washing machine: this code is in config\packages\washing_machine.yaml
### ALL CODE RELATED TO THE WASHING MACHINE ###
input_select:
washing_machine_state:
name: Washine Machine is
icon: mdi:washing-machine
options:
- 'Off'
- Idle
- Running
initial: 'Off'
tplink:
discovery: false
switch:
- host: 192.168.0.60
sensor:
- platform: template
sensors:
washing_machine_power:
friendly_name: "Washing Machine Power Consumption"
value_template: '{{ states.switch.washing_machine.attributes["current_power_w"] | float }}'
### <2W = off # Power readings at various states of the washing cycle for reference
### >3W = idle
### >7W = filling
### >90W = washing
### >200W = spin
automation:
- alias: 'Washing maching -status tracker- Idle'
trigger:
- platform: numeric_state
entity_id: sensor.washing_machine_power
above: 2
for: '00:00:05'
action:
- service: input_select.select_option
data:
entity_id: input_select.washing_machine_state
option: Idle
- alias: 'Washing maching -status tracker- Running'
trigger:
- platform: numeric_state
entity_id: sensor.washing_machine_power
above: 5
for: '00:00:05'
action:
- service: input_select.select_option
data:
entity_id: input_select.washing_machine_state
option: Running
- alias: 'Washing machine -status tracker- Off'
trigger:
- platform: numeric_state
entity_id: sensor.washing_machine_power
below: 2
for: '00:01:00'
action:
- service: input_select.select_option
data:
entity_id: input_select.washing_machine_state
option: 'Off'
- alias: 'Washing machine finished notification'
trigger:
- platform: state
entity_id: input_select.washing_machine_state
from: Running
to: Idle
- platform: state
entity_id: input_select.washing_machine_state
from: Running
to: 'Off'
action:
- service: notify.mobile_phones
data:
message: 'The washing machine has finished'
data:
ttl: 0
priority: high
Have a look in the dev states panel to see that entity. Likely you will need to use the state rather than attribute. Itâs just that your entity is different to mine.