{"action":"created","issue":{"url":"https://api.github.com/repos/kizniche/mycodo_python/issues/1","labels_url":"https://api.github.com/repos/kizniche/mycodo_python/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/kizniche/mycodo_python/issues/1/comments","events_url":"https://api.github.com/repos/kizniche/mycodo_python/issues/1/events","html_url":"https://github.com/kizniche/mycodo_python/issues/1","id":120590216,"number":1,"title":"Conditional Relays","user":{"login":"Cabalist","id":828557,"avatar_url":"https://avatars.githubusercontent.com/u/828557?v=3","gravatar_id":"","url":"https://api.github.com/users/Cabalist","html_url":"https://github.com/Cabalist","followers_url":"https://api.github.com/users/Cabalist/followers","following_url":"https://api.github.com/users/Cabalist/following{/other_user}","gists_url":"https://api.github.com/users/Cabalist/gists{/gist_id}","starred_url":"https://api.github.com/users/Cabalist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cabalist/subscriptions","organizations_url":"https://api.github.com/users/Cabalist/orgs","repos_url":"https://api.github.com/users/Cabalist/repos","events_url":"https://api.github.com/users/Cabalist/events{/privacy}","received_events_url":"https://api.github.com/users/Cabalist/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-05T21:51:24Z","updated_at":"2015-12-05T22:34:49Z","closed_at":null,"body":"Hey @kizniche,\r\n\r\nCould you explain what conditional relays are?  \r\n\r\nI am specifically looking at this block of code below that was in ```relay_onoff()```.  This is executed after the relay is turned on/off and max amps are checked.\r\n\r\n```python\r\n    for i in range(len(conditional_relay_id)):\r\n        if state == 'on':\r\n            if conditional_relay_ifrelay[i] == relay and conditional_relay_ifaction[i] == 'on' and conditional_relay_ifduration[i] == 0:\r\n                if conditional_relay_sel_relay[i]:\r\n                    if conditional_relay_doaction[i] == 'on' and conditional_relay_doduration[i] != 0:\r\n                        rod = threading.Thread(target=relay_on_duration, args=(conditional_relay_dorelay[i], conditional_relay_doduration[i], 0, relay_trigger, relay_pin,))\r\n                        rod.start()\r\n                    else:\r\n                        relay_onoff(conditional_relay_dorelay[i], conditional_relay_doaction[i])\r\n                if conditional_relay_sel_command[i]:\r\n                    p = subprocess.Popen(conditional_relay_do_command[i], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r\n                    output, errors = p.communicate()\r\n                    logging.debug(\"[Relay Conditional %s (%s)] Execute command: %s Command output: %s Command errors: %s\", i, conditional_relay_name[i], conditional_relay_do_command[i], output, errors)\r\n                if conditional_relay_sel_notify[i] and conditional_relay_time_notify[i] < time.time():\r\n                    logging.debug(\"[Relay Conditional %s (%s)] True: Notify %s\", i, conditional_relay_name[i], conditional_relay_do_notify[i])\r\n                    if conditional_relay_doaction[i] == 'on' and conditional_relay_doduration[i] != 0:\r\n                        message = \"Relay Conditional %s (%s): Relay %s turned %s for %s seconds.\" % ((i), conditional_relay_name[i], relay, conditional_relay_doaction[i], conditional_relay_doduration[i])\r\n                    else:\r\n                        message = \"Relay Conditional %s (%s): Relay %s turned %s.\" % ((i), conditional_relay_name[i], relay, conditional_relay_doaction[i])\r\n                    email(conditional_relay_do_notify[i], message)\r\n                    conditional_relay_time_notify[i] = time.time() + smtp_wait_time\r\n                elif conditional_relay_sel_notify[i]:\r\n                    logging.debug(\"[Relay Conditional %s (%s)] True: Waiting to notify %s. %s seconds left to wait to be able to notify again (of %s seconds).\", i, conditional_relay_name[i], conditional_relay_do_notify[i], (smtp_wait_time - (smtp_wait_time - (conditional_relay_time_notify[i] - time.time()))), smtp_wait_time)\r\n        elif state == 'off':\r\n            if conditional_relay_ifrelay[i] == relay and conditional_relay_ifaction[i] == 'off':\r\n                if conditional_relay_sel_relay[i]:\r\n                    if conditional_relay_doaction[i] == 'on' and conditional_relay_doduration[i] != 0:\r\n                        rod = threading.Thread(target=relay_on_duration, args=(conditional_relay_dorelay[i], conditional_relay_doduration[i], 0, relay_trigger, relay_pin,))\r\n                        rod.start()\r\n                    else:\r\n                        relay_onoff(conditional_relay_dorelay[i], conditional_relay_doaction[i])\r\n                if conditional_relay_sel_command[i]:\r\n                    p = subprocess.Popen(conditional_relay_do_command[i], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r\n                    output, errors = p.communicate()\r\n                    logging.debug(\"[Relay Conditional %s (%s)] Execute command: %s Command output: %s Command errors: %s\", i, conditional_relay_name[i], conditional_relay_do_command[i], output, errors)\r\n                if conditional_relay_sel_notify[i] and conditional_relay_time_notify[i] < time.time():\r\n                    if conditional_relay_doaction[i] == 'on' and conditional_relay_doduration[i] != 0:\r\n                        message = \"Relay Conditional %s (%s): Relay %s turned %s for %s seconds.\" % ((i), conditional_relay_name[i], relay, conditional_relay_doaction[i], conditional_relay_doduration[i])\r\n                    else:\r\n                        message = \"Relay Conditional %s (%s): Relay %s turned %s.\" % ((i), conditional_relay_name[i], relay, conditional_relay_doaction[i])\r\n                    email(conditional_relay_do_notify[i], message)\r\n                    conditional_relay_time_notify[i] = time.time() + smtp_wait_time\r\n                elif conditional_relay_sel_notify[i]:\r\n                    logging.debug(\"[Relay Conditional %s (%s)] True: Waiting to notify %s. %s seconds left to wait to be able to notify again (of %s seconds).\", i, conditional_relay_name[i], conditional_relay_do_notify[i], (smtp_wait_time - (smtp_wait_time - (conditional_relay_time_notify[i] - time.time()))), smtp_wait_time)\r\n```"},"comment":{"url":"https://api.github.com/repos/kizniche/mycodo_python/issues/comments/162254117","html_url":"https://github.com/kizniche/mycodo_python/issues/1#issuecomment-162254117","issue_url":"https://api.github.com/repos/kizniche/mycodo_python/issues/1","id":162254117,"user":{"login":"kizniche","id":838427,"avatar_url":"https://avatars.githubusercontent.com/u/838427?v=3","gravatar_id":"","url":"https://api.github.com/users/kizniche","html_url":"https://github.com/kizniche","followers_url":"https://api.github.com/users/kizniche/followers","following_url":"https://api.github.com/users/kizniche/following{/other_user}","gists_url":"https://api.github.com/users/kizniche/gists{/gist_id}","starred_url":"https://api.github.com/users/kizniche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kizniche/subscriptions","organizations_url":"https://api.github.com/users/kizniche/orgs","repos_url":"https://api.github.com/users/kizniche/repos","events_url":"https://api.github.com/users/kizniche/events{/privacy}","received_events_url":"https://api.github.com/users/kizniche/received_events","type":"User","site_admin":false},"created_at":"2015-12-05T22:34:49Z","updated_at":"2015-12-05T22:34:49Z","body":"I don't know if you've used the web interface, but there's alt/title text for most inputs, that give additional information when the mouse is hovered over it.\r\n\r\nDo you want a more detailed explanation of the function, or did my previous comments explain it well enough?"}}