Quantcast
Channel: Configuration - Home Assistant Community
Viewing all 106012 articles
Browse latest View live

Extracting multiple attributes from JSON?

$
0
0

@Hurde wrote:

I’m using the RESTful integration to acquire data for my bus stop, especially the next three departures for a specific bus line. I’m trying to fetch these values from the JSON response and use them in a sensor. My sensor configuration is below:

  - platform: rest
    method: POST
    name: HSL_LPV_550
    resource: https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql
    payload: '{  stop(id: "HSL:1463113")   {    stopTimesForPattern(id: "HSL:2550:0:01", numberOfDepartures: 3)     {    	realtimeArrival      }  }}'
    headers:
      Content-Type: application/graphql

The POST request gives a response of:

{
  "data": {
    "stop": {
      "stopTimesForPattern": [
        {
          "realtimeArrival": 71746
        },
        {
          "realtimeArrival": 72527
        },
        {
          "realtimeArrival": 72892
        }
      ]
    }
  }
}

The above response contains the desired next three departures, the format is seconds from midnight.

However, here comes the tricky part. I would like to use the values to determine the sensor value and a sensor attribute according to the following formula (I’m comparing the realtimeArrival to the current time):

IF:
the difference on first timestamp and current time is under 4 minutes, set the second timestamp difference as sensor value and third timestamp difference as sensor attribute called next.
ELSE:
set the first timestamp difference as sensor value and second timestamp difference as sensor attribute called next.

I could extract the time difference of first arrival and current time in minutes using the following:

{% set current_time = ((now().hour*60+now().minute)*60+now().second) %}
{% set arrival_time = (value_json.data.stop.stopTimesForPattern[0].realtimeArrival) %}
{% set ETA = ((arrival_time-current_time)/60)  | int %}

My issue could be broken to the following parts:

  1. I don’t know how to extract all three values of the JSON reply and use them in value_template, as they have same names
  2. I don’t know how I can use IF-ELSE statement as described above, this seems trivial as long as I have the three values available somewhere.

Posts: 5

Participants: 3

Read full topic


Automation start at time from inputer_number

$
0
0

@Hunt4Beer wrote:

Hello,

I need some help with my automation. I try to start my vacuum at a time which I set with an input_number slider. The slider just adjust the hour, so I compare the current hour with the slider.

- id: '1558202812387'
  alias: Staubsaugen Uhrzeit
  trigger:
  - platform: template
    value_template: '{{ now().hour == (states("input_number.uhrzeit_staubsauger")
      | int )}}'
  condition: []
  action:
  - entity_id: vacuum.rockrobo
    service: vacuum.start

The template works fine. I tested it in the “developer tool / template”.
The template is “true” if the current hour matches the value of the input_number.

Somehow the automation doesn’t start, so it seems to be a problem with the trigger.

I hope some of you can help me.
Thank you in advance.

Posts: 5

Participants: 4

Read full topic

Fetching a token every hour

$
0
0

@danielo515 wrote:

Hello.
I want to run a rest command every hour to fetch an auth token and then I want to use that token in some other automations.
I can’t find any good way of doing this.
If this were a normal application I will just make a post request and store the result token in some temporary variable, but I don’t find any HASSIO way of doing this.
What I tried so far:

  • Set the basic auth (username and password) in secrets.yaml
  • Because you can’t access secrets from templates ( I don’t understand this limitation) create an input text to hold the secret values
  • Create a rest sensor that uses the input text values like this:
- platform: rest
  resource: http://192.168.0.121/cgi-bin/api.cgi?cmd=Login&token=null
  method: POST
  payload: '[{"userName":"{{ states.input_text.xxx_user.state }}","password":"{{ states.input_text.xxx_password.state }}"}]'  
  value_template: '{{ value_json.0.value }}'
  json_attributes:
    - value.Token.lease_time 
    - value.Token.name 

And that’s all for now. The rest sensor has been failing but I don’t know why because I don’t know what is the exact request it is doing. Is there any log where I can see the actual request? If I try a curl request with this same values I get a satisfactory response, which looks like this:

[
   {
      "cmd" : "Login",
      "code" : 0,
      "value" : {
         "Token" : {
            "leaseTime" : 3600,
            "name" : "the-actual-token-value"
         }
      }
   }
]

Do you know of any other better approach?
I would love to use AppDaemon, but it seems to be a silo where you can’t fetch values from.

Thanks in advance

Posts: 8

Participants: 3

Read full topic

YAML: did not find expected key while parsing a block mapping again

Picture Element for latest version of Hassio

$
0
0

@PearmG wrote:

I am trying to use a picture of my home’s layout and overlay buttons for lights and locks. But the only information I can find uses older versions of Lovelace. Any new tutorials anyone can point me too?

Posts: 1

Participants: 1

Read full topic

Configure lovelace cards as side panels

$
0
0

@Miicroo wrote:

I have a few input_booleans and input_numbers to configure things like when and if automations should run. It is nice to have them in the UI so I don’t have to change the config every time I would like to update the values. However, the frontend feels kind of cluttered when I add them, and usually I just end up with lots of tabs with configuration. Instead I would like to add them as different side panels (like HACS and configuration panel and such). Is there an easy way to create such a side panel without having to code a custom panel in javascript? I dont mind coding it, I just prefer to configure it just like the main UI if I can :slight_smile:

Posts: 2

Participants: 2

Read full topic

Failed to create automation with trigger numeric value from input_number

$
0
0

@oferfrid wrote:

Hi
I have a numeric value (from slider)

  boiler_save_temperature:
    name: Save Temperature
    initial: 50
    min: 40
    max: 70
    step: 10

I can view it’s value using tamplate:

> {{ states('input_number.boiler_save_temperatur') | float }}
I’ve tried to use this value in automation:

- id: '1580322266512'
  alias: Boiler set on
  description: ''
  trigger:
  - below: "{{ states('input_number.boiler_save_temperatur') | float }}"
    entity_id: sensor.boiler_ds18b20_temperature
    for: 0:00:05
    platform: numeric_state
  condition:
  - condition: state
    entity_id: switch.boiler
    state: 'off'
  - below: "{{ states('input_number.boiler_save_temperatur') | float }}"
    condition: numeric_state
    entity_id: sensor.boiler_ds18b20_temperature
  action:
  - data:
      entity_id: switch.boiler
    service: switch.turn_on

this is the error i get:

Invalid config for [automation]: expected float for dictionary value @ data['condition'][1]['below']. Got None
expected float for dictionary value @ data['trigger'][0]['below']. Got None. (See /config/configuration.yaml, line 151)

Posts: 4

Participants: 3

Read full topic

Automation using the sun not working

$
0
0

@benzo wrote:

Hello,
I tried to automate a scene to turn on 45 minutes before the sunset, like the example in the offical link https://www.home-assistant.io/cookbook/automation_sun/ but it didn’t work.
Before testing sunset automation i was using a simple time trigger event that worked like a charm. Now in the log i see many errors but i don’t know why happening only with sunset automation.

This is the simple automation:

  - alias: 'Accendi Luci Salotto'
    trigger:
      - platform: sun
        event: sunset
        offset: "-00:45:00"
    action:
      service: scene.turn_on
      entity_id: scene.Accendi_Luci_Salotto
      data:
        transition: 900
  - alias: 'Spegni Luci Salotto'
    trigger:
      - platform: time
        at: '00:30:00'
    action:
      service: scene.turn_on
      entity_id: scene.Spegni_Luci_Salotto         

The log:

Error while executing automation automation.accendi_luci_salotto. Invalid data for call_service at pos 1: extra keys not allowed @ data[‘transition’]

components/hue/sensor_base.py(ERROR)
Unable to reach bridge 192.xxx.xxx.xxx ()

I know that “extra keys not allowed @ data[‘transition’]” is the error but it can stop the automation entirely???

Posts: 4

Participants: 2

Read full topic


Smartthings Integration Stopped Working

$
0
0

@MRV wrote:

I had Smartthings integration working fine for months. Then it just stopped working. All of my devices showed up as “unavailable” and could not be controlled by HA. But the hub is working and I can still control from Smartthings app or via Alexa using the Smartthings skill.

I deleted the Smartthings integration and also deleted the old api token in the Smartthings website. I then tried creating a new token and reinstalling the integration. HA accepts the token and says that the integration has been created, but it has no devices whatsoever. HA can’t see ANY of Smartthings devices.

What just happened??!!

I am running HA 103 on a Linux Ubuntu PC, in a docker container.

Anyone know what happened?

Posts: 3

Participants: 3

Read full topic

Automation template: Invalid data for call_service expected int for dictionary value @ data['position']

$
0
0

@metaloide wrote:

Hi all,

Thanks all in advance for you help, this is my first post in the community.

I’m facing an automation error that I’m unable to resolve. I’ve tried many combinations and differnt approaches but I keep getting following error:

2020-01-29 21:56:00 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.programa_persiana. Invalid data for call_service at pos 2: expected int for dictionary value @ data['position']

I’m trying to setup an automation to set blinds at specific position at specific times.

  • 6:20 set cover.persiana_cocina at position 90
  • 19:30 set cover.persiana_dormitorio at 35
  • 21:30 set cover.persiana_cocina at 35.
  • In all cases, a notification should also be sent informing of the hour it was executed at.

And here my failing automation:

- id: '1579878523506'
  alias: Programa-persiana
  description: ''
  trigger:
  - at: '19:30'
    platform: time
  - at: '21:56'
    platform: time
  - at: '6:20'
    platform: time
  action:
  - service: cover.set_cover_position
    data_template:
      entity_id: cover.persiana_cocina
      position: '{% if trigger.now.hour == 21 %} 35 {% endif %}'
  - service: cover.set_cover_position
    data_template:
      entity_id: cover.persiana_cocina
      position: '{% if trigger.now.hour == 6 %} 90 {% endif %}'
  - service: cover.set_cover_position
    data_template:
      entity_id: cover.persiana_dormitorio
      position: '{% if trigger.now.hour == 19 %} 35 {% endif %}'
  - data_template:
      message: "Programa-persiana triggered at {{ trigger.now.hour }}"
    service: notify.ha_besalu

The thing is that the first cover cover.persiana_cocina is correctly set to the position but then the error is thrown and no notification is sent. I’ve tried many things without any luck.

Thanks for your help!

Posts: 3

Participants: 3

Read full topic

iCloud integration - Hide if Away from Home

$
0
0

@Markus99 wrote:

Been having issues w/ the icloud integration since upgrade to .104.3 - not blaming it on the upgrade, but I used to have it configured in configuration.yaml and it would no longer update. It also had a device in known_devices.yaml - which I set in there to:

hide_if_away: true

I then removed it from configuration.yaml and known_devices (as well as the files in .storage), rebooted, added it into Configuration-> Integrations section - which is working again (it seems) - but now the device isn’t in known_devices any longer and I can’t configure it to hide_if_away.

I also added it to customize.yaml:

device_tracker.XXX_ipad:
  hide_if_away: true

But still showing on the map…

Question is then, how can I add this hide_if_away attribute to the device when configured via Configuration -> Integrations? End goal is to remove it from the map entirely if there’s another way to do this

Posts: 2

Participants: 2

Read full topic

Deleting Leading Spaces in YAML

$
0
0

@Tangston311 wrote:

My configuration.yaml is starting to get outrageously long so I was thinking of splitting the file into multiple pieces using the !include function for my automations, scripts, scenes, etc…

Because I’ve set everything up in configuration.yaml, my spacing is like so:

scene:
  - name: Scene 1
    entities:
      cover.entry_entry_left_shade:
        position: 100
      cover.entry_entry_right_shade:
        position: 100
      cover.library_library_shade:
        position: 100

But I need to change it to:

Configuration.yaml
scene: !include scenes.yaml

Scenes.yaml

- name: Scene 1
  entities:
    cover.entry_entry_left_shade:
      position: 100
    cover.entry_entry_right_shade:
      position: 100
    cover.library_library_shade:
      position: 100

So I have to delete the leading two spaces of every line for every scene to get it to work in the new scenes.yaml (at least that’s my understanding). Does anyone know of an easy way to do that aside from manually deleting it from each line?

Posts: 10

Participants: 9

Read full topic

Recurring Issue with an unresponsive frontend

$
0
0

@mnetwork wrote:

I have been having an issue for a while where randomly when I try to load Home Assistant on my phone I get stuck at the “Loading Data” screen. Also, I use GPS Logger (Android) to track myself and there are many polls throughout the day that time out. This is resulting in delayed/skipped automations and the inability to open the frontend at random times. While the issue is occurring I can remote to my home computer and get on the frontend without issue. I can even get in from another phone (new login). This is not an issue with my data connection as I run a constant ping to my house and I’m usually actively using data. Today it was happening on my ten minute walk home. The last few minutes of the walk I couldn’t load the frontend on my primary phone and GPS Logger was timing out each time it tried to send an update. During this time I was able to get to the frontend using my work phone. The second my phone switched to wifi when I got to my house I was able to load the frontend and GPS Logger was able to submit a poll. This issue is driving me crazy and I’m not exactly sure how to troubleshoot it.

Posts: 1

Participants: 1

Read full topic

Spofity media player TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

$
0
0

@luisfosoares wrote:

I’m seeing up Spotify for media player but each time I try to stop/pause I get the following error:

unsupported operand type(s) for &: ‘NoneType’ and ‘int’
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 134, in handle_call_service
connection.context(msg),
File “/usr/src/homeassistant/homeassistant/core.py”, line 1226, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File “/usr/src/homeassistant/homeassistant/core.py”, line 1251, in _execute_service
await handler.func(service_call)
File “/usr/src/homeassistant/homeassistant/helpers/entity_component.py”, line 201, in handle_service
self._platforms.values(), func, call, service_name, required_features
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 335, in entity_service_call
future.result() # pop exception if have
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 350, in _handle_service_platform_call
entity.supported_features & feature_set for feature_set in required_features
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 350, in
entity.supported_features & feature_set for feature_set in required_features
TypeError: unsupported operand type(s) for &: ‘NoneType’ and ‘int’

My config for Spotify is :
media_player:

  • platform: spotify
    client_id:
    client_secret:

and my Lovelace config is :
entity: media_player.spotify
type: media-control

Any help?

Posts: 1

Participants: 1

Read full topic

Template error with only light devices

$
0
0

@FutureTense wrote:

Very strange:

value_template: {{ states.climate.living_room.state }}

Output: value_template: heat

While the following throws an error

value_template: {{ states.light.2frb4_fr_spotlight }}

Error rendering template: TemplateSyntaxError: expected token ‘end of print statement’, got ‘frb4_fr_spotlight’

These are ISY lights if it makes any difference. I can see their states just fine in the developer tab

Posts: 5

Participants: 4

Read full topic


Automationeditor strange behavior

$
0
0

@kolossboss wrote:

Last night I created a simple automation with the Editor. Everything looks good. This morning I waked up and I was wondering why a few devices are triggered.
I looked into HA and I found out, that all of the automations are shown duplicated but with the “enabled” state!
I reloaded the automations and all duplicateds are gone, but now 70 % of my automations are gone too…
Also the automations.yaml was nearly emty.
Fortunately I made a snapshot evey night (not this night because automation was gone) so I can restore the automation.yaml.

Nothing in the LOGS.
What can causes this?

Posts: 2

Participants: 2

Read full topic

Trigger automation based on date from template

$
0
0

@matejdro wrote:

Hello,

Is there any way to dynamically trigger automation based on date from template?

More specifically, I’m using Google Calendar integration. Calendar sensor has start_time attribute. I want my automation to trigger 10 minutes before the start time.

Ideally, I would want some automation to trigger whenever calendar sensor updates and schedule another automation for exactly 10 minutes before the start time. But I cannot find a good way to do this. At the moment I’m just updating the automation every 10 minutes and filtering it with condition template which is a bit wasteful.

Is there a better way to do this?

Posts: 1

Participants: 1

Read full topic

Sunset event and related actions out of sync

$
0
0

@pensionado wrote:

I have blinds closing at sunset and I have lights going on 15 minutes before that, but when I look in the logbook, yesterday 15 minutes before sunset happened at 17:00, blinds closed at 17:15 and logbook reports sunset at 17:23 ??? 8 minutes out. Anybody else see this phenomena ? The event table showed that yesterdays next-rising was as follows: next_setting:2020-01-29T16:15:55+00:00, which matches the lights and blind action(UTC+1), so why is sunset in log at 17:23 ?

Posts: 1

Participants: 1

Read full topic

Why is there a GUI and YAML mode for Lovelace settings

$
0
0

@Askarus wrote:

What is the reason for Lovelace having a YAML and an GUI mode for settings.
When in GUI mode I can edit raw YAML to add elements and the YAML is translated into GUI configuration.

So why does it not update and read from the ui-lovelace.yaml file in the first place.
For me it would combine the best of both worlds: Being able to modify the UI within the Web interface and easy external modification and backup of the settings.

Each option misses the best of the other option in my opinion.

Posts: 1

Participants: 1

Read full topic

Noob question: Looking for "components/hassio/__init__.py"

$
0
0

@cpo wrote:

Now i feel stupid,

i just wanted to rebbot my Hass.io (on Pi) and get this (checking config beforehand):

“Platform error sensor.huesensor - No module named ‘custom_components.huesensor.sensor’
9:43 components/hassio/init.py (ERROR)”

i only got “huesensor” and “hacs” in my “custom component” and i do not find any reference to a “module named ‘custom_components.huesensor.sensor’” anywhere, neither a file called “components/hassio/init.py”.

Could anybody help me with that? Perhaps i’m just a bit hazy right now…

Posts: 1

Participants: 1

Read full topic

Viewing all 106012 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>