Skip to content

Instantly share code, notes, and snippets.

@lipkau
Last active December 15, 2020 02:33
Show Gist options
  • Save lipkau/463b1e6393b420af8eaa0173fabca0c2 to your computer and use it in GitHub Desktop.
Save lipkau/463b1e6393b420af8eaa0173fabca0c2 to your computer and use it in GitHub Desktop.
FHEM definition for a washing machine connected to a PCA301 socket and sending a push notification once it's finished
# Logger
{ restoreDir_mkDir("./log", "jeelink/washer", 0) }
define FileLog_Washer FileLog ./log/jeelink/washer/%Y-%m-%d.log Washer
attr FileLog_Washer logtype text
attr FileLog_Dishwasher nrarchive 14
attr FileLog_Washer room Bathroom
{ restoreDir_mkDir("./log", "push", 0) }
define FileLog_Push FileLog ./log/push/%Y-%m-%d.log push_.*
attr FileLog_Push logtype text
attr FileLog_Push nrarchive 14
attr FileLog_Push room PushChannels
# All phones with PushNotifier installed
define push_all PushNotifier <token> <com.app> <username> <password> .*
attr push_all room PushChannels
# Washer with PCA301 power socket
define Washer PCA301 019CCA 05
attr Washer IODev myJeeLink
attr Washer devStateIcon on:on:toggle off:off:toggle set.*:light_exclamation:off
attr Washer userReadings status { if (ReadingsVal($name,'power',0) >= 5) {return 'running'} else { return 'idle' } }
attr Washer webCmd on:off:toggle:statusRequest
attr Washer room Bathroom
# Determine that washer is finished based on consumption
define notify_washer_state notify Washer:stat(e|us).* { \
if (ReadingsVal("Washer","state","off") eq "off") { \
{ fhem("set dummy_notify_washer_finished_state none") } \
} elsif (ReadingsVal("Washer","status","none") eq "running") { \
{ fhem("set dummy_notify_washer_finished_state armed") } \
} elsif ((ReadingsVal("Washer","status","none") eq "idle") && (Value("dummy_notify_washer_finished_state") eq "armed")) { \
{ fhem("set push_all message Washing Machine is finished") } \
{ fhem("set dummy_notify_washer_finished_state triggered") } \
} else { \
{ fhem("set dummy_notify_washer_finished_state none") } \
} \
}
attr notify_washer_state disabledAfterTrigger 60
attr notify_washer_state room Events
define dummy_notify_washer_finished_state dummy
attr dummy_notify_washer_finished_state room Bathroom
attr dummy_notify_washer_finished_state setList state:none,armed,triggered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment