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

How do I pass data from service call to a template in a script?

$
0
0

@xescure wrote:

smart_toggle:
  sequence:
    service_template: >
      {% if is_state("group.bedroom", "on") %}
        homeassistant.turn_off
      {% else %}
        homeassistant.turn_on
      {% endif %}
    data_template:
      entity_id: "{{ entity_id }}"

In this script I have already successfully pulled the entity_id that was put in as an argument for the script’s service call, but I would like to also use it in the service_template. Like this: {% if is_state("{{ entity_id }}", "on") %} However that doesn’t seem to work.

Any ideas?

Posts: 4

Participants: 2

Read full topic


HA v0.103, HACS v0.19 Howto get ZHA-network-card to work?

$
0
0

@jorgenn wrote:

Hi

I’m trying to get ZHA-network-card to work on my installation off HA.
I’m running HA v.0.103 and HACS v0.19 on an RPI4.
I’m not able to get this community plugin to work, or any other one either, So I’m would like to find out what I’m doing wrong.

SO Can any one provide me with an step by step instruction on how to get this plugin up and running ?

Posts: 1

Participants: 1

Read full topic

Select source for DenonAVR with Homekit

$
0
0

@Anders_Ovreseth wrote:

Hi everyone! I am quite new to HA, but have managed to get a lot done by reading up on posts by others. However, I am stuck with the following problem;

  • I have added a Denonavr media player successfully, including adding a nice control in the webgui where I can change source
  • I have added homekit to my configuration and added the entity media_player.tv_stue so that I also see this unit in my Home app in IOS
  • Currently I am only able to add the following features on_off, toggle_mute

My goal is to be able to change source from the Home app, but I am unable to find the appropriate way to add a feature so that this is available without ending up with errors in my homekit configuration.

Can anyone help me?

Best regards,
Anders
– configuration.yaml –

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

customize: !include customize.yaml

# Example configuration.yaml entry
media_player:
        - platform: denonavr
          host: 10.160.1.32
          name: Tv-stue
          show_all_sources: true
#    zones:
#      - zone: Zone2 / Zone3
#        name: NAME
#

homekit:
        include_entities:
                - media_player.tv_stue

        entity_config:
                media_player.tv_stue:
                        feature_list:
                                - feature: on_off
                                - feature: toggle_mute

Posts: 1

Participants: 1

Read full topic

DB Credentials, Python Script, Update last_changed at Startup

$
0
0

@Markus99 wrote:

Having issues where restarts are resetting last_changed time of numerous entities - so I figured I’d try to hack together a python script that I can execute in an automation upon HA startup to reset the last_changed time of a handful of entities.

After various searches and piecing a number of forum threads together, I’ve unfortunately reached at a stand-still. I’m running Hassio in Docker on a NUC. I’m an Ubuntu NOOB, so used this: https://www.juanmtech.com/set-up-hassio-in-docker-and-in-an-ubuntu-server/ to setup Hassio on the NUC.

I’ve created a /config/python_scripts directory and added :python_script to configuration.yaml

I’ve created a real_last_change.py script (code immediately below) and put it in /config/python_scripts/

import sys
import pymysql.cursors
from datetime import timezone

## entity_id = sys.argv[1]
entity_id  = data.get('entity_id')

mysql_host = '127.0.0.1'
mysql_user = 'user'
mysql_pass = 'pass'
mysql_db   = 'homeassi'

def utc_to_local(utc_dt):
    return utc_dt.replace(tzinfo=timezone.utc).astimezone(tz=None)

db = pymysql.connect (host=mysql_host, user=mysql_user, passwd=mysql_pass, db=mysql_db)
cursor = db.cursor(pymysql.cursors.DictCursor)

sql = """SELECT state,last_changed FROM states WHERE entity_id = '%s'
         ORDER BY created DESC LIMIT 100""" % (entity_id)

cursor.execute(sql)
result = cursor.fetchall()
db.close()

for idx, row in enumerate(result):
    state_act = row['state']
    date_act = row['last_changed']
    if idx == 0:
        state_last = state_act
        date_last = date_act
    if state_last != state_act:
        real_last_changed = date_last
        break
    else:
        state_last = state_act
        date_last = date_act

print(utc_to_local(real_last_changed).strftime('%Y-%m-%d %H:%M:%S'))

I’m trying to execute in developer tools -> services as such:
image

The intended result is to scan the DB and update the entity’s (switch.front_drive_gate) last_changed time to the ACTUAL (not reboot) last time changed.

I’m fairly certain the entity_id = data.get('entity_id') code will correctly used the passed data from the service call correctly, but I can’t, after much searching, figure out what credentials to use to access the DB. Without these, I’m unable to fully test the python script, so could be errors in there I haven’t reached yet.

Anyhow, thanks in advance for any time / help spent / given!

Posts: 2

Participants: 2

Read full topic

How to read the next 4 characters from the last occasion of a string from a textfile?

$
0
0

@boneheadfraggle wrote:

I have a Zipato/Schlage Mini Keypad and I’m trying to get a hold of which user code was used for the arm/disarm.
I have found the string in the OZW_Log.txt that indicates the user code slot, so now I just need to find the string to make a sensor or attribute out of it.

At a certain state change, I want to search the OZW_Log.txt for "Received: 0x01, 0x10, 0x00, 0x04, 0x00, 0x06, 0x0a, 0x71, 0x05, 0x00, 0x00, 0x00, 0xff, 0x06, 0x06, 0x01, ", then grab the following 4 characters and put that in a sensor.

Any suggestions how to accomplish that?

Posts: 2

Participants: 2

Read full topic

Hass.io VM with remote Pi as GW for Enocean (or Zigbee)

$
0
0

@jottt wrote:

Maybe it’s simple and I just haven’t found the right way to search for it… if so, thanks for pointing in the right direction:

I have a powerful ESXi-Server and a Pi 2 with an Enocean-Module. For my setup it would be best to have hass.io/Homeassistant running on the VM-Server but using the Pi (with any linux) as the communicator to Enocean (and possibly to Zigbee as well in future). Is it possible to setup the Pi as a kind of satellite/gateway?

Thanks!

Posts: 1

Participants: 1

Read full topic

Automation question about temperature sensor

$
0
0

@solomos wrote:

Hello,
I have install on my baby’s room a temperature / humidity sensor. It works great.

I have create an automation to receive alerts & notify when humidity is over 70%.

image

However I don’t want the automation to run during the morning.
I want it to run between 16.00 - 01:00 and if the humidity is 70% and more for over 45 minutes.

Added the following condition to achieve it

image

My problem is that I never get a notification even if the humidity is over 70%.
The notify / alert works. I think something is wrong with my condition.

I checked the daily graph of the humidity sensor and it go over 70% on the specified time frame (16.00 - 01:00)

image

Any help would be much appreciated .

Posts: 5

Participants: 4

Read full topic

Instead integration?

$
0
0

@davidsbach wrote:

The website suggests that Home Assistant has an Insteon integration, but after installing I do not find one. Is there a working Insteon integration for the 2413U PLM?

Posts: 2

Participants: 2

Read full topic


Automation with motion + door sensors and timer problems

$
0
0

@henaa wrote:

Hi
What wrong with this automation?
Even motion state on. The light and media player turn off after 1:30 minute

I want the media player and light turn off only if no any motion and door close. after 1:30 minute.

timer:
  bathroom:
    duration: '00:01:30'
- id: '1576684838552'
  alias: Bathroom on Motion Timed
  description: ''
  trigger:
  - entity_id: binary_sensor.motion_sensor_158d0002f07f28
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: timer.bathroom
    service: timer.start
- id: '1576685072616'
  alias: End of Timer in Bathroom
  description: ''
  trigger:
  - event_data:
      entity_id: timer.bathroom
    event_type: timer.finished
    platform: event
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.door_window_sensor_158d00035ac62a
      state: 'off'
  action:
  - data:
      entity_id: media_player.googlehome4082
    service: media_player.turn_off
  - data:
      entity_id: light.64341605b4e62d5e979e
    service: light.turn_off

Posts: 1

Participants: 1

Read full topic

Zwave - August setup

$
0
0

@krock wrote:

Hi all - I need some help setting up my August lock with Z-wave.
So far, I added configuration for zwave in my configuration.yaml file, added a key, and can see it in the Lovelace interface… just not sure how to pair the two. Thanks in advance!

Posts: 1

Participants: 1

Read full topic

RESTful Binary Sensor not working after migrating from Hassbian to HassIO

$
0
0

@Zoriontsu wrote:

After end of support for Hassbian was announced, I started the process of migrating to HassIO.
So far, after lots of tweaks, almost everything is working fine.

This rest binary sensor to check for movement at camera will not work anymore.
Works fine if I execute from SSH command line. ANY HELP IS APPRECIATED!!

#------------------------------------------------------------------------------------------------------------------------------------
# Sensor to determine if there is motion at the FOSCAM Cameras
#------------------------------------------------------------------------------------------------------------------------------------
  - platform: rest
    name: "Gate Motion"
    resource: !secrets gate_motion_resource
    device_class: motion
    scan_interval: 5
    value_template: >-
      {%- if "<motionDetectAlarm>2</motionDetectAlarm>" in value -%}
        {{ true }}
      {%- else -%}
        {{ false }}
      {%- endif -%}

Posts: 1

Participants: 1

Read full topic

Nest OAuth info. SD card died. What to do?

$
0
0

@brucehvn wrote:

I had my nest thermostat setup in HA. My SD card for HA in my pi completely died yesterday and I found I didn’t have the nest client_id and client_secret backed up anywhere. It appears I can’t retrieve it anymore from the works with nest website as the “Products” link just goes to the Google FAQ’s.

Since I’m now setting up my whole HA from scratch again, is there anyway to integrate my nest thermostat? Google talks about migrating your works with nest account to Google, but I’m not sure if that would help or even how to do it.

Posts: 2

Participants: 2

Read full topic

Template Sensor JSON Possibly

$
0
0

@Bartem wrote:

So I was in the middle of making template sensor to pull the ‘Areas Of Interest’ attribute from the geocoded location sensor made by the iOS app… when the value was populated it was coming up in brackets and quotes in the template editor

['Value Looked Like This']

… my wife is now home so that field is now coming up as: N/A so I can’t exactly test it any further at the moment. I guess it looks like JSON, I was hoping maybe someone with the app/or familiar with parsing that could just give me a quick pointer on how to get that to populate that without the quotes or brackets. All the examples I see refer to JSON using rest sensors/command line sensors, etc…

Maybe I just need to send the wife back out… :grimacing:

Posts: 1

Participants: 1

Read full topic

Cannot re-add SmartThings to my hass installation

$
0
0

@Oscar_Calvo wrote:

After following a failed update from 0.103.1 back to 0.103.0, and removing my SmartThings integration, now I cannot add the SmartThings integration.

The problem happena in the SmartThings app, as another instance of NabuCase smart app exists in my account.

Anyway to resolve this issue?

Posts: 1

Participants: 1

Read full topic

Am I supposed to define where each item is?

$
0
0

@jriker1 wrote:

So I’ve been going down the HA route for a little bit now and was thinking as I start installing Z-Wave wall switches and the fact that my echobee asked me this. Is there a way I’m supposed to be defining which room or area each of my items are in?

Posts: 2

Participants: 2

Read full topic


Forcing a fresh scan of device trackers?

$
0
0

@Coedy wrote:

Is it possible to force a scan/update of device trackers?

I’ve seen the device_tracker.see service, but this appears to spoof the device tracker to a particular place/zone.

Basically, I use ping and home assistant android location tracking, my wife only uses ping.
I have a sensor on my front door.
I planned on making the door sensor trigger an update of the device trackers, rather than waiting for when they next update by themselves, this should mean I will be recognised as home within seconds rather than minutes.

Is there a way? or is there any plans to add this service?

I think the other option I have is add a third tracker - Monitor (bluetooth) as this appears to allow me to set it up to manually scan whenever I like.
It’s just the WAF that doesn’t fly with this “I’m not having PIs all around the bloody house!”. After I get a 3D printer I may see if it’s possible to run monitor on ESP32s as these are less bulky and easier to hide!

Posts: 4

Participants: 2

Read full topic

Service with empty entity_id

$
0
0

@SinisteR wrote:

Hi there, this is my first post and I hope it will not be very dumb :slight_smile:

I’ve successfully finished a project for using an water accumulation tank as an energy storage for photo voltaic panels. However I have had bad luck when I was editing my automation with visual studio plugin. I’ve got a connection drop and visual studio for some reason wiped my automation file blank. Now I am trying to write the code again with the same logic (or at least I think it was like that) but I am crashing on “Invalid data for call_service at pos 2: not a valid value for dictionary value @ data[‘entity_id’]” in the log. I am aware that my templates can produce an empty entity_id for the service, that’s because to omit the service action in some cases. I don’t know if this is allowed but also I think it was working like this before.

Here is the code:

- alias: Solar Water Heating Power Injection
# The purpose of the automation is to use the accumulation tank of the house as a battery.
# There are two 3-phase heating elements top/bottom (heating wires) in the 700l accumulatioln tank.
# There is digitally controlled SCR installed in L3 phase.
  trigger:
    platform: state
    entity_id: sensor.solaredge_current_power, sensor.house_current_power
  condition:
    condition: state
    entity_id: binary_sensor.solar_overproduction
    state: 'on'
  action:
  # The first part of action should roughly set the power feed to the water heating elements by setting the power phases
  # Variables ht1 and ht2 are the tresholds for phases. ht1 is equal to the power of the single phase heating element power, ht2 = ht1 * 2 
  # turn off the non-needed phases or do nothing (empty entity_id)
  - service: switch.turn_off
    data_template:
      entity_id: "{% if (states('sensor.solaredge_current_power') | int
        - states('sensor.house_current_power_without_heating') | int)
        < states.variable.ht1.state | int %}
        switch.water_heating_L1, switch.water_heating_L2
        {% elif (states('sensor.solaredge_current_power') | int
        - states('sensor.house_current_power_without_heating') | int)
        < states.variable.ht2.state | int %}
        switch.water_heating_L1
        {% endif %}"
  # turnd on needed phases or do nothing (empty entity_id)
  - service: switch.turn_on
    data_template:
      entity_id: "{% if (states('sensor.solaredge_current_power') | int 
        - states('sensor.house_current_power_without_heating') | int) > states.variable.ht2.state | int %}
        switch.water_heating_L1, switch.water_heating_L2
        {% elif (states('sensor.solaredge_current_power') | int 
        - states('sensor.house_current_power_without_heating') | int) > states.variable.ht1.state | int %}
        switch.water_heating_L1
        {% endif %}"
  # this section regulates SCR attached to L3 phase for fine adjustment of the heating power
  # SCR has range from 0 to 100 steps and two +/- buttons
  # The purpose with this code is to press +/- buttons until the photovoltaic production = house consumption +/- 10W
  # press + or - button, or do nothing if the power is in balance
  - service: switch.turn_on
    data_template:
      entity_id: "{% if (states('sensor.solaredge_current_power') | int - states('sensor.house_current_power') | int) > 10 %}
        switch.Water_Heating_L3_power_step_up
        {% elif (states('sensor.house_current_power') | int - states('sensor.solaredge_current_power') | int ) > 10 %}
        switch.Water_Heating_L3_power_step_down
        {% endif %}"
  # release the button press, no matter which one was pressed
  - service: switch.turn_off
    entity_id: switch.Water_Heating_L3_power_step_up, switch.Water_Heating_L3_power_step_down
  # get the instant re-measurement (this sould also loop the whole automation as it will change sensor.house_current_power state)
  - service: mqtt.publish
    data_template:
      topic: 'cmnd/water_heating_L3/STATUS'
      payload: 10
  id: 53a32e3e3b69477e96e5edc082634dc9

Thanks in advance for your opinions!

Posts: 2

Participants: 2

Read full topic

Emulated hue after .103.2

$
0
0

@joe8mofo wrote:

So i nuked my emulated_hue_ids.json and upgraded to .103.2. Now my log is flooded with these entries.

2019-12-19 11:15:50 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 16 not found in emulated_hue_ids.json
2019-12-19 11:15:54 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 20 not found in emulated_hue_ids.json
2019-12-19 11:16:03 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 14 not found in emulated_hue_ids.json
2019-12-19 11:16:13 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 27 not found in emulated_hue_ids.json
2019-12-19 11:16:14 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 18 not found in emulated_hue_ids.json
2019-12-19 11:16:18 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 12 not found in emulated_hue_ids.json
2019-12-19 11:16:20 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 18 not found in emulated_hue_ids.json
2019-12-19 11:16:24 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 20 not found in emulated_hue_ids.json
2019-12-19 11:16:28 ERROR (MainThread) [homeassistant.components.emulated_hue.hue_api] Unknown entity number: 26 not found in emulated_hue_ids.json

I then proceeded to remove emulated hue from my configuration.yaml. restarted HA, then brought it back and restarted HA again and still the system is failing to create a new emulated_hue_ids.json.

Posts: 4

Participants: 2

Read full topic

Wake up light alarm

$
0
0

@Ptitmickey wrote:

Hello guys,

I’m trying to create an automation to wake me up with light transition.
I’ve readed this post :


And this article:

I would like a mix between this two codes

It could be nice to :

  • add a “light transition time” in lovelace card
  • create a new sensor "wakeup time which show “alarm time” - “light transition time”
  • use wakeup time like automation start
  • use “light transition time” in script in place of fixed value

Configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml

#Reveil
input_boolean :
  wakeup_enabled:
    name: "Reveil lumineux"
    initial: on
    icon: mdi:theme-light-dark
  wakeup_weekend:
    name: "Activer reveil le week-end"
    initial: off # I disable the system on default on weekends
    icon: mdi:calendar-blank

input_datetime:
  wakeup_time:
    name: "Heure du reveil"
    has_time: true
    has_date: false
    initial: "07:20"

  wakeup_duration:
    name: "Duree du reveil"
    has_time: true
    has_date: false
    initial: "0:15"

Sensors.yaml

- platform: time_date

Automations.yaml

- alias: "Me reveiller dans la chambre avec transition lumineuse"
  trigger:
    platform: template
    value_template: "{{ states('sensor.time') == (states.input_datetime.wakeup_time.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  condition:
    - condition: state
      entity_id: input_boolean.wakeup_enabled
      state: 'on'
    - condition: or
      conditions:
        - condition: state
          entity_id: input_boolean.wakeup_weekend
          state: 'on'
        - condition: time
          weekday:
            - mon
            - tue
            - wed
            - thu
            - fri
  action:
    - service: script.wakeup_bedroom

Scripts.yaml

  wakeup_bedroom:
    alias: 'Wakeup lighting, smooth transition'
    sequence:
      - service: light.turn_on
        data_template:
          entity_id: light.plafonnier_chambre
          brightness: 1
          kelvin: 1500
      - service: light.turn_on
        data_template:
          entity_id: light.plafonnier_chambre
          brightness: 255
          kelvin: 5000
          transition: '30'

Maybe could you help me to modify my configuration files to get this requests.
I’m learning yaml files but need some more informations to get this work.

Thanks for all.

Posts: 1

Participants: 1

Read full topic

Ring video playback

$
0
0

@narsaw wrote:

I’ve setup the Ring component along with using a picture-glance card. Everything seems to work well, except the video playback when selected seems to play in fast forward mode. It looks to playing at 2x the speed as compared when playing via the Ring app.

Anyone experience this?

Posts: 2

Participants: 2

Read full topic

Viewing all 105614 articles
Browse latest View live


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