Greenhorn need automation help

I’m not an absolutely greenhorn but I feel like one right now…

I’ve been working with industrial automation and instrumentation for close to 4 decades, have set up one Zipatile system, one Fibaro HC2 system, given up on OpenHAB (needed FAR too much help to get the most basic functions to work and by reading the support forum, I have the impression that I need to work with OpenHAB 24/7/365 to get the hang of it…) and now I am trying to do a similar thing in Home Assistant and I’m quite stuck…

Hardware: RaspberryPi 3B+ with Aeotec Z-Wave dongle and at the moment one Telldus TZWP-100 Plug-in Switch.

The system is up and runnnig and that went fairly smooth, the Telldus unit can be operated thru the HA main page and also if I operate it with the pushbutton directly on the unit, the status changes immediately on HA main page. So far, so good…

Right now, I only want to automatically turn off the Telldus unit 90 minutes after it has been turned on regardless of where it was turned on and that should be quite simple in my head. I have read the documentation and forum for LOTS of hours and experimented a lot, taken code examples and adapted but absolutely no sucsess…

My automation script looks like this right now (90 minutes changed to 3 sec just for the testing):

alias: Telldus_test
trigger:
    platform: state
    entity_id: switch.telldustest
    to: 'on'
    for:
      seconds:    3
action:
  - service: switch.turn_off
    entity_id: switch.telldustest

Home Assistant.log:

2018-09-13 16:56:50 WARNING (MainThread) [homeassistant.components.http] legacy_api_password support has been enabled. If you don’t require it, remove the ‘api_password’ from your http config.
2018-09-13 16:57:09 WARNING (MainThread) [homeassistant.setup] Setup of config is taking over 10 seconds.
2018-09-13 16:57:25 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
2018-09-13 16:57:29 WARNING (SyncWorker_3) [netdisco.ssdp] Found malformed XML at http://172.16.0.100:55642:
invalid request
2018-09-13 16:57:36 WARNING (MainThread) [aiohttp.websocket] websocket connection is closing.
2018-09-13 16:57:44 ERROR (SyncWorker_7) [homeassistant.components.remote.harmony] No activity specified with turn_on service
2018-09-13 16:57:48 ERROR (SyncWorker_15) [homeassistant.components.remote.harmony] No activity specified with turn_on service
2018-09-13 16:57:50 ERROR (SyncWorker_1) [homeassistant.components.remote.harmony] No activity specified with turn_on service
2018-09-13 16:57:53 ERROR (SyncWorker_16) [homeassistant.components.remote.harmony] No activity specified with turn_on service

I have one Harmony remote that I haven’t included in the systeem (yet) but it still appears in the log making errors.

Any help would be greatly appreciated.

In general I think the automation is correct

Some things to try. Go to the States page in the frontend (in the left pane, under Developer Tools.) Find automation.telldus_test in the list. Is its state on? Also, click the the little icon next to it (it’s a box with an arrow.) In the dialog that appears, click on the word TRIGGER. (Make sure the switch is on first.) Does this make the switch go off? (By clicking TRIGGER you’re forcing the actions of the automation to run.)

The item “switch.telldus_tzwp100_plugin_switch_switch” responds to the correct state on or off.

By using that item in my automation, it works almost as expected. The 3 seconds is not quite accurate and may be a random time up to 10 seconds but that is no big deal at this time.

Earlier, I did try with “zwave.telldus_tzwp100_plugin_switch” but that didn’t work.

Thanks for pointing me to the States page, I see that that may be a key to these issues.

This probably has more to do with how long it takes HA to become aware of a change of state that was initiated externally (i.e., via the push button on the switch itself) than the responsiveness of HA itself. If you turn the switch on via HA it should turn off almost exactly 3 seconds later.

All of the pages listed under Developer Tools (with maybe the exception of Events – I haven’t personally found too much use for that one) will become your bosom buddies! :slight_smile:

[quote=“pnbruckner, post:4, topic:68458”]
This probably has more to do with how long it takes HA to become aware of a change of state that was initiated externally (i.e., via the push button on the switch itself) than the responsiveness of HA itself. If you turn the switch on via HA it should turn off almost exactly 3 seconds later. [/quote]

When operating the pushbutton on the device, the status changes on-screen within milliseconds.

So then the switch’s state must be changing back and forth for a bit. When you have a state trigger and you specify the “to” state and a “for” period, that automation will trigger almost exactly that amount of time after the entity first changes to that state, as long as it stays that state for the entire time period. Based on my experience, the only way that the actions would get delayed (beyond the 3 seconds) would be if the entity’s state changed to something other than ‘on’ during the 3 seconds (resetting the timer.) You might want to take a closer look at the state history of that switch entity.