{"action":"created","issue":{"url":"https://api.github.com/repos/OttoWinter/esphomeyaml/issues/104","repository_url":"https://api.github.com/repos/OttoWinter/esphomeyaml","labels_url":"https://api.github.com/repos/OttoWinter/esphomeyaml/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/OttoWinter/esphomeyaml/issues/104/comments","events_url":"https://api.github.com/repos/OttoWinter/esphomeyaml/issues/104/events","html_url":"https://github.com/OttoWinter/esphomeyaml/issues/104","id":352635959,"node_id":"MDU6SXNzdWUzNTI2MzU5NTk=","number":104,"title":"Help setting up latching solenoid/relay","user":{"login":"pyrosmiley","id":11056798,"node_id":"MDQ6VXNlcjExMDU2Nzk4","avatar_url":"https://avatars0.githubusercontent.com/u/11056798?v=4","gravatar_id":"","url":"https://api.github.com/users/pyrosmiley","html_url":"https://github.com/pyrosmiley","followers_url":"https://api.github.com/users/pyrosmiley/followers","following_url":"https://api.github.com/users/pyrosmiley/following{/other_user}","gists_url":"https://api.github.com/users/pyrosmiley/gists{/gist_id}","starred_url":"https://api.github.com/users/pyrosmiley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyrosmiley/subscriptions","organizations_url":"https://api.github.com/users/pyrosmiley/orgs","repos_url":"https://api.github.com/users/pyrosmiley/repos","events_url":"https://api.github.com/users/pyrosmiley/events{/privacy}","received_events_url":"https://api.github.com/users/pyrosmiley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-21T17:21:25Z","updated_at":"2018-09-20T06:29:28Z","closed_at":null,"author_association":"NONE","body":"Hi Otto, thanks for dealing with my dumb issues as they come up! I really have scoured the docs for this one and it _seems_ like I should be able to do it, but I can't _quite_ get it there. \r\n\r\nI need to control a latching solenoid valve, with two separate GPIO pins going to an h-bridge. Right now I have two `switch` instances set up, one each for `set` and `reset` functions, and two `template switch`  for `on` and `off` that pulses the proper GPIO output, and that's what's exposed to Home Assistant. For simply turning on and off a valve, it works. This is all based on the [Template Cover](https://esphomelib.com/esphomeyaml/components/cover/template.html) example I found in the docs. Unfortunately, there's no sensor to help determine the state. \r\n\r\nNormally I'd just let that be that and move on with life, except for the fact that I also need to use Deep Sleep, and I have to be able to have a value to store in nonvolatile memory (or, ideally, the [RTC Memory](https://www.youtube.com/watch?v=r-hEOL007nw)!). I haven't gotten to the stage of figuring out how I'm gonna do that yet but I know it should be do-able because you already have it implemented with the `light` component so I'll probably just poke around in the C code for those. In an effort to be other-user-friendly, I also need to be able to toggle the state of the valve with a single button for each, but that'll be simple once I have a unified switch to actually toggle.\r\n\r\nMy other plan was to try and just set it up in Home Assistant, which isn't ideal, but might work since it stays up while the ESPs are sleeping. Unfortunately, ESPHY is smart enough to turn off the all the outputs when it wakes up. Not so good for 3 minute deep sleep when I wanna water the garden for 30 minutes....\r\n\r\nIn the meantime, I've been trying and failing to set one up with a `template binary sensor` and an API call to toggle the state as part of the `set` and `reset` actions. I thought for sure this would be the method that works, but alas, I can't seem to write it such that it will have an initial value without referencing something else, and there's nothing to reference. \r\ntl;dr\r\n- Separate pulsed GPIO pins for `set` and `reset` ✔️\r\n- Templated `state` value based not on the physical outputs, but the `on` and `off` actions of unified template switch 😕\r\n - Save state to nonvolatile memory for persistence across deep sleeps 🤷‍♂️\r\n\r\nI really hope I'm not missing something, but I asked on the Discord to no avail, and my head is just spinning in circles to make this one work."},"comment":{"url":"https://api.github.com/repos/OttoWinter/esphomeyaml/issues/comments/423056134","html_url":"https://github.com/OttoWinter/esphomeyaml/issues/104#issuecomment-423056134","issue_url":"https://api.github.com/repos/OttoWinter/esphomeyaml/issues/104","id":423056134,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzA1NjEzNA==","user":{"login":"pyrosmiley","id":11056798,"node_id":"MDQ6VXNlcjExMDU2Nzk4","avatar_url":"https://avatars0.githubusercontent.com/u/11056798?v=4","gravatar_id":"","url":"https://api.github.com/users/pyrosmiley","html_url":"https://github.com/pyrosmiley","followers_url":"https://api.github.com/users/pyrosmiley/followers","following_url":"https://api.github.com/users/pyrosmiley/following{/other_user}","gists_url":"https://api.github.com/users/pyrosmiley/gists{/gist_id}","starred_url":"https://api.github.com/users/pyrosmiley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyrosmiley/subscriptions","organizations_url":"https://api.github.com/users/pyrosmiley/orgs","repos_url":"https://api.github.com/users/pyrosmiley/repos","events_url":"https://api.github.com/users/pyrosmiley/events{/privacy}","received_events_url":"https://api.github.com/users/pyrosmiley/received_events","type":"User","site_admin":false},"created_at":"2018-09-20T06:29:28Z","updated_at":"2018-09-20T06:29:28Z","author_association":"NONE","body":"Ah okay, interesting!! I didn't realize RTC memory messes with OTA. Definitely do _not_ want to break that!\r\n\r\nI also did not quite realize that that's how `optimistic` works.... That's my bad -- I guess it just didn't stick with me somehow. Thanks!"}}
{"actor":{"display_login":"pyrosmiley"}}