Mini-graph-card: Example - More info

Created on 28 Jul 2019  路  7Comments  路  Source: kalkih/mini-graph-card

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?

question

Most helpful comment

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.

All 7 comments

Ping @michaelblight, Would you mind sharing it? 馃檪

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.

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.

@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?

@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.

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?

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simonwood0609 picture simonwood0609  路  7Comments

tomlut picture tomlut  路  4Comments

yadenisenko picture yadenisenko  路  4Comments

Joezi79 picture Joezi79  路  4Comments

brezuicabogdan picture brezuicabogdan  路  5Comments