Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example - More info #127

Closed
xstrex opened this issue Jul 28, 2019 · 7 comments
Closed

Example - More info #127

xstrex opened this issue Jul 28, 2019 · 7 comments
Labels
question Further information is requested

Comments

@xstrex
Copy link

xstrex commented Jul 28, 2019

In the last example on your wiki, your using input_number.nighttime to show sun-up/sun-down. Would you mind sharing the HA config for that input_number?

@kalkih kalkih added the question Further information is requested label Jul 30, 2019
@kalkih
Copy link
Owner

kalkih commented Jul 30, 2019

Ping @michaelblight, Would you mind sharing it? 🙂

@michaelblight
Copy link
Collaborator

michaelblight commented Jul 31, 2019

I mainly use the Node Red add-on for automation in HA, so the field is just a simple input which NR then populates. So the HA config is:

input_number:
  nighttime:
    name: Night
    min: 0
    max: 1

And the NR flow is:
Screen Shot 2019-07-31 at 5 57 29 pm

And it's a NR add-on called node-red-node-suncalc that gives me sunrise and sunset. The NR code for the screen-shot above is:

[{"id":"400e2f26.d7bb9","type":"sunrise","z":"f6747993.c9b448","name":"","lat":"-37.813630","lon":"144.9977","start":"sunrise","end":"dusk","x":170,"y":1280,"wires":[["db67ec3.d54731"],[]]},{"id":"2cc91956.57b696","type":"api-call-service","z":"f6747993.c9b448","name":"Set","server":"9a5aae17.6700c","service_domain":"input_number","service":"set_value","data":"{\"entity_id\":\"input_number.nighttime\"}","mergecontext":"","output_location":"","output_location_type":"none","x":530,"y":1280,"wires":[[]]},{"id":"db67ec3.d54731","type":"change","z":"f6747993.c9b448","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    \"data\": {\t        \"value\":\t            (payload = 1 ? 0 : 1)\t    }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1280,"wires":[["2cc91956.57b696"]]},{"id":"9a5aae17.6700c","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]

There's probably a simpler way to do it in straight HA automation.

@michaelblight
Copy link
Collaborator

I think you could do it in HA along the lines of:

  trigger:
    platform: sun
    event: sunset
    offset: "-00:45:00"
  action:
    entity_id: input_number.nighttime
    service: input_number.set_value
    data:
      value: 1

And for sunrise:

  trigger:
    platform: sun
    event: sunrise
    offset: "-00:45:00"
  action:
    entity_id: input_number.nighttime
    service: input_number.set_value
    data:
      value: 0

Adjusting the offsets as you see fit.

@kalkih kalkih closed this as completed Aug 8, 2019
@shawtux
Copy link

shawtux commented Nov 9, 2019

@michaelblight i used your config, but i'm getting an error:
"Call-service API error. Error Message: Service not found."
on the set part.

Any ideas?

@michaelblight
Copy link
Collaborator

michaelblight commented Nov 10, 2019

@shawtux Which version are you using - the first (NR) or the second (HA)? Either way, you should try using the "Services" tab under the "Developer Tools" menu in HA to ensure that everything works there first.

@shawtux
Copy link

shawtux commented Nov 10, 2019

Thanks!
Everything works until the action.
I'm using version NR because the HA I've didn't change states.

Actually, in the services I don't have input_number.set_value. could this be it?

@shawtux
Copy link

shawtux commented Nov 10, 2019

@michaelblight change from node-red (memory hog) to the home assistant.

Found out that to have this service, one needs to add in the configuration the following:

input_number:
  slider1:
    name: Slider
    initial: 30
    min: -20
    max: 35
    step: 1
  box1:
    name: Numeric Input Box
    initial: 30
    min: -20
    max: 35
    step: 1
    mode: box
  nightime:
    name: Nightime value
    initial: 0
    min: 0
    max: 1
    step: 1
    mode: box

if this isn't added, then the service called is not available.

Now it works with the HA config as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants