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

Calculate Doubling rate

$
0
0

@hajo62 wrote:

I would like to calculate the doubling rate of the COVID-19 data.
The formula is: ln(2) / ln(1 - (n_today-n_yesterday) / n_yesterday)
ln means the mathematical function natural logarithm.

Questions:
Is there a way to use the yesterdays value of a sensor?
How to calculate a natural logarithm?

Any other ideas to get value from Covid data?

Posts: 1

Participants: 1

Read full topic


How to use variables within a conditional

$
0
0

@kleverson02 wrote:

I have a problem, I want to reuse the code of a script, passing the variables to him, but within the conditional he is not able to read.

code:
( input_select )
radiodespertadorsala:
name: ‘Escolha a Rádio’
options:
- ORF Radio

(script)
despertadorsala:
alias: Despertador da Sala
sequence:
- service: script.turn_on
entity_id: script.despertador
data:
variables:
entidade: media_player.jogos
radio: input_select.radiodespertadorsala

( script for reuse )
despertador:
alias: despertador
sequence:
- service: media_player.volume_set
data_template:
entity_id: ‘{{entidade}}’
volume_level: ‘0.40’
- service: media_player.play_media
data_template:
entity_id: ‘{{entidade}}’
media_content_id: >
{% if is_state("{{radio}}", “ORF Radio”) %}
http://mp3stream2.apasf.apa.at:8000/;stream/1
{% endif %}
media_content_type: ‘audio/mp4’

the problem is that the radio variable is not read inside the if, I’m probably putting the wrong syntax, I would like help

Ty

Posts: 4

Participants: 3

Read full topic

Automation isn't being triggered

$
0
0

@mwarner wrote:

Hello,

I am completely new to Home Assistant. So to start off this my goal is to have Home Assistant Dim the two lights in my living room when I play media on my Vizio TV. Which I tend to use SmartCast were it uses the plex app to play my media.

Currently the lights that I have are the walmart Merkury, which with Tuya. I do have them added to Home Assistant and can turn the lights on and off via the Home Assistant dashboard.

I’ve created an automation script, and scene script. I’ve check that the automation works by forcing it to execute and triggering the scene, which my livingroom lights do dim and go back to normal, so that portion works. The issue I think is that plex, or smartcast is not triggering the automation. Below are my configs.

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

tuya:
  username: SecretEmail
  password: SecretPassword
  country_code: 86

plex:
  host: MyServerIP
  port: 32400
  media_player:
    use_episode_art: true
    ignore_new_shared_users: false

scene:
  - name: Livingroom normal
    entities:
        light.06200636b4e62d1a727e:
            state: on
            transition: 2
            brightness: 100
        light.62118678dc4f22bc7378:
            state: on
            transition: 2
            brightness: 100
  - name: Livingroom dim
    entities:
        light.06200636b4e62d1a727e:
            state: on
            transition: 2
            brightness: 1
        light.62118678dc4f22bc7378:
            state: on
            transition: 2
            brightness: 1

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

automations.yaml

- id: '1585550781277'
  alias: Playing Media
  description: ''
  trigger:
  - entity_id: media_player.plex_plex_for_vizio_vizio_smartcast
    from: idle
    platform: state
    to: playing
  condition: []
  action:
  - scene: scene.livingroom_dim
- id: '1585550904757'
  alias: Stopped Media
  description: Media is either not playing, or paused.
  trigger:
  - entity_id: media_player.plex_plex_for_vizio_vizio_smartcast
    from: playing
    platform: state
    to: idle
  condition: []
  action:
  - scene: scene.livingroom_normal

Posts: 12

Participants: 4

Read full topic

Amazon echo duplicates wreaking havoc with HA interactions

$
0
0

@jr3us wrote:

I have figured out the ‘magic’ required to fix the above reference problems between HA and the echo devices.

The fix I have found is to do the following:

remove all devices in the echo device list.
deregister all of the echo devices, and add one of them back.
scan for devices again, and the duplicates will go away!

I tore out my hair trying to figure out why it was goofin with me for a couple days!

Posts: 1

Participants: 1

Read full topic

Problem with multiple dashboards Lovelace

$
0
0

@GooN wrote:

I´m trying to get the multiple dashboards of lovelace inplace. But I can´t seam to get it to work. I have added the following to configuration.yaml

lovelace:
  mode: storage
  resources:
    - url: /community_plugin/compact-custom-header/compact-custom-header.js
      type: module
    - url: /community_plugin/mini-media-player/mini-media-player.js
      type: module
    - url: /community_plugin/bignumber-card/bignumber-card.js
      type: module
    - url: /local/list-card-scroll.js?v=0
      type: module
    - url: https://unpkg.com/moment@2.22.2/min/moment-with-locales.min.js
      type: module
    - url: /local/clock-card/clock-card.js
      type: module
    - url: /community_plugin/circle-sensor-card/circle-sensor-card.js
      type: module
    - url: /community_plugin/lovelace-markdown-mod/markdown-mod.js
      type: module
    - url: /community_plugin/button-card/button-card.js
      type: module
    - url: /community_plugin/mini-graph-card/mini-graph-card.js
      type: module
    - url: /community_plugin/calendar-card/calendar-card.js
      type: module
  dashboards:
    lovelace-generated: # Needs to contain a hyphen (-)
      mode: yaml
      filename: notexist.yaml
      title: Generated
      icon: mdi:tools
      show_in_sidebar: true
      require_admin: true
    lovelace-yaml:
      mode: yaml
      title: Dashboard
      icon: mdi:script
      show_in_sidebar: true
      require_admin: false
      filename: dashboard.yaml

But the diffrent dashboards wont show up in the UI. Only the dashboards created in the UI shows up.

Anyone having the same problem?

/Anders

Posts: 2

Participants: 2

Read full topic

Run daily Python script (Warmtemeter) including Imports ( HA on HassOS @ ESX)

$
0
0

@CowboyTW wrote:

All,

I have this modified script (See below) in my python_script folder and it works fine when run from SSH console. Now I want to retrieve the data from my district theater once a day so I need to schedule it. Tried/reviewed online very quickly with Node-RED, Crontab, Python-script, Custom Components, AppDaemon but was not successful yet.

Hoped for simply doing a automation calling the python-script once a day but due to imports and limited functionality on that side can’t get this to work. Crontab no option as this is not persistent and running in the SSH console container probably. Node-red and Custom components were still too complex for me, need to learn a bit more by trial and error.

Any advise? Thanks!
-Tom

#!/usr/bin/python3
###############################################################################
# Stadsverwarming UT550 script for Home Assistant                             #
# Version 0.3 - Author: RuntimeError123 / L. Bosch                            #
# Updated for UT50/550T by tomw@xs4all.nl - 30/Mar/2020                       #
###############################################################################
# Importing modules
#################################
import os
import re
import serial
import requests
from time import sleep
import yaml
import json

# Loading config YAML file
#################################
configfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), \
'stadsverwarming-config.yaml')
config = yaml.safe_load(open(configfile))
destination = config['main']['destination']

# Load mqtt and ssl if mqtt is selected
#################################
if destination == 'mqtt':
    import paho.mqtt.client as mqtt
    if 'certificate' in config['mqtt']:
        import ssl

# Declaring variables
#################################
    broker = config['mqtt']['broker']
    port = config['mqtt']['port']
    if 'username' in config['mqtt']:
        username = config['mqtt']['username']
        password = config['mqtt']['password']
    if 'certificate' in config['mqtt']:
        certificate = config['mqtt']['certificate']
        tls_version = config['mqtt']['tls_version']
        tls_insecure = config['mqtt']['tls_insecure']
    topic = config['mqtt']['topic']
    retain = config['mqtt']['retain']

# Function Lees telegram
#################################

conn = serial.Serial('/dev/ttyUSB1',
                     baudrate=300,
                     bytesize=serial.SEVENBITS,
                     parity=serial.PARITY_EVEN,
                     stopbits=serial.STOPBITS_TWO,
                     timeout=1,
                     xonxoff=0,
                     rtscts=0
                     )

# Wake up
conn.setRTS(False)
conn.setDTR(False)
sleep(5)
conn.setDTR(True)
conn.setRTS(True)

# send /?!
conn.write(str.encode("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2F\x3F\x21\x0D\x0A"))

# Read at 300 BAUD, typenr
print(conn.readline())
print(conn.readline())

# Read at 2400 BAUD, higher might be possible
conn.baudrate=2400

# Read 18 lines (the size of the telegram)
counter = 0
try:
    while counter < 18:
        line=conn.readline().decode('utf-8')
        print(line)

        # This will match on the first line of the telegram with GJ and m3 values.
        matchObj = re.match(r".+6\.8\(([0-9]{4}\.[0-9]{3})\*GJ\)6\.26\(([0-9]{5}\.[0-9]{2})\*m3\)9\.21\(([0-9]{8})\).+", line, re.I|re.S)
        if matchObj:
            kjValue=round(float(matchObj.group(1))*1000)
            m3Value=round(float(matchObj.group(2))*1000)
            print("GJ : " + str(kjValue))
            print("m3: " + str(m3Value))
        counter = counter + 1
finally:
    conn.close()

# Decode and transform new data
###############################
new_energy = str(kjValue)
new_volume = str(m3Value)
new_temp_in = 0  # Looks like this data is not available in heater's datagram
new_temp_out = 0
    
# Updating values
###############################

state = json.dumps({'Energy' : new_energy, \
'Volume' : new_volume, \
'Temperature_in' : new_temp_in, \
'Temperature_out' : new_temp_out})
mqttc = mqtt.Client()
mqttc.connect(broker, port=port)
mqttc.loop_start()
mqttc.publish(topic, state, retain=retain)
mqttc.disconnect()
mqttc.loop_stop()
print("MQTT data published: " +state)
print("Energy: "+str(new_energy))
print("Volume: "+str(new_volume))
print("Temperature in: "+str(new_temp_in))
print("Temperature out: "+str(new_temp_out))

Posts: 2

Participants: 2

Read full topic

Why are my automations not sorted alpabetically?

$
0
0

@fribse wrote:

I have a mix of automatically created automations and ‘hand made’.
At some point in the later revisions of HA, some of them stopped appearing in alphabetical order.
an example:


I’m not sure, but it seems to be happening if I rename the automation.
This makes it rather complicated to find the automations.
So why does this happen, and how do I fix it?

I’ve started moving quite a few of them to node-red, so the problem gets less and less, but it’s still really odd?

Posts: 3

Participants: 3

Read full topic

VPN + iptables. How do I drop traffic from specific IP outside VPN

$
0
0

@ninjadog wrote:

  • So I’m running NGINX and a VPN server , on my cloud VPS,
  • VPN server IP on the VPN is 10.19.49.1.
  • Nginx redirects certain subdomain traffic to my VPN clients.
  • One of the VPN clients is running HA.
  • Client IP on the VPN is 10.19.49.2.
  • On the HA instance , how do I block incoming traffic originating from a specific public IP because my VPN client is receiving all traffic from the VPN server and thus will only “see” my VPN server IP.

Whats happening currently is that on the VPN client running HA I added an iptables rule to drop IP 1.2.3.4 to the INPUT chain (default filter table) .

iptables -A INPUT -s 1.2.3.4 -j DROP

However, I also added logging to INPUT chain and every incoming packet SRC was my VPN server 10.19.49.1 which is correct - but the “originating” IP was 1.2.3.4 which accessed my subdomain , went to my VPS, reverse proxied to my VPN client via my VPN server. All correct, but as SRC on my VPN client incoming packet is always 10.19.49.1 then traffic from 1.2.3.4 is not getting dropped.

This will be easy for a networking guru , but I am at the extent of my knowledge now and stuck.

Posts: 1

Participants: 1

Read full topic


Automation triggers only once

$
0
0

@FlangeMonkey wrote:

Hi Guys,

So I have the following, it’s my first automation and it works. It changes my harmony to the correct outputs on my amp when Chromecast is playing. However, when I turn the Chromecast to the off state (by stopping the cast) and turn casting back on, the automation fails to execute.

Any ideas?

Thanks,

  alias: ChromeCast Living Room - Speakers - Turn on
  description: When ChromeCast Living Room is playing, turn on Harmony to Cast Audio
  trigger:
  - entity_id: media_player.living_room_speakers
    from: 'off'
    platform: state
    to: playing
  condition: []
  action:
  - device_id: 22e1bc4be6a8485d8d3a0b1914607cac
    domain: switch
    entity_id: switch.cast_audio_harmony_activity
    type: turn_on

Posts: 13

Participants: 4

Read full topic

Scene not setting brightness

$
0
0

@jjross wrote:

I built some scenes using the editor but I’m finding that when I execute the scenes the brightness of the light stays at 100% even though the brightness slider is at 5% (the value in the scene). The values are al correct in the generated YAML.

There seems to be a disconnect between the slider (and the value set in the scene) and what actually happens when the scene is set.

Not sure how to narrow down whether this is an HA issue or an issue with MQTT or Tasmota. Any suggestions?

Posts: 4

Participants: 3

Read full topic

Xiaomi Aqara D1 - 3 gang wall switch Zigbee

$
0
0

@gurbina93 wrote:

So it has been a while since the Xiaomi Aqara Single and Double key Zigbee switches came out, one of the easiest and hassle free switches that require no neutral cable.

Now there seems to be a three gang switch


https://shopee.com.my/-迷你插座排线-小米Aqara绿米智能墙壁开关三键-天猫精灵智能家居无线遥控面板d1-i.200808776.7622561544

Has anyone tried it yet? Nothing on the integration page and nothing in the forum regarding this new version. I have barely been able to find it.

There also seems to be a Yeelight version of the switch for smart bulbs (it doesn’t seem to be smart at all). Any hints on what does it do exactly?

I just wanna replace my standard three gang switches for Zigbee ones.

Posts: 1

Participants: 1

Read full topic

CEC Scanner Issue

$
0
0

@jungo wrote:

Hello everyone, HA newbie here :slight_smile:

I Installed HA using the default hass.io method on RPi 3B+
My RPi is connected to my TV via HDMI
I would like to configure the CEC plugin

When tryting to run the CEC Scanner I get the following error:

[08:08:02] INFO: Starting CEC client scan...
opening a connection to the CEC adapter...
ERROR:   [              55]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [              55]	Open - vc_cec could not be initialised
ERROR:   [              55]	could not open a connection (try 1)
ERROR:   [            1056]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            1056]	Open - vc_cec could not be initialised
ERROR:   [            1056]	could not open a connection (try 2)
ERROR:   [            2057]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            2057]	Open - vc_cec could not be initialised
ERROR:   [            2057]	could not open a connection (try 3)
ERROR:   [            3057]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            3057]	Open - vc_cec could not be initialised
ERROR:   [            3057]	could not open a connection (try 4)
ERROR:   [            4064]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            4064]	Open - vc_cec could not be initialised
ERROR:   [            4064]	could not open a connection (try 5)
ERROR:   [            5064]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            5064]	Open - vc_cec could not be initialised
ERROR:   [            5064]	could not open a connection (try 6)
ERROR:   [            6065]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            6065]	Open - vc_cec could not be initialised
ERROR:   [            6065]	could not open a connection (try 7)
ERROR:   [            7066]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            7066]	Open - vc_cec could not be initialised
ERROR:   [            7066]	could not open a connection (try 8)
ERROR:   [            8069]	RegisterLogicalAddress - CEC is being used by another application. Run "tvservice --off" and try again.
ERROR:   [            8069]	Open - vc_cec could not be initialised
ERROR:   [            8070]	could not open a connection (try 9)

Searching for a solution led me to this link but it didn’t provide much info on how to troubleshoot
I tried to ssh into the hass system using the SSH addon but I wasn’t able to find or install the tvservice utility.

What is the proper way to address this issue? I’m a bit familiar with linux but when I ssh I can’t find any installed tools or ways to install tools (apt / yum / etc.)

Thanks
Omer

Posts: 1

Participants: 1

Read full topic

What does this error meaning?

$
0
0

@Canedje wrote:

I do receive this error in my logfile:

:0:0 Script error.

March 30, 2020, 9:43:42 PM – components/system_log/__init__.py (ERROR) - message first occurred at March 30, 2020, 7:09:30 PM and shows up 2 times

What does this mean? and what to do?
I’m running HA 0.107.7 and supervisor 214

Posts: 1

Participants: 1

Read full topic

FV 123solar with modbus 485 and Home assistant

$
0
0

@wifi75 wrote:

Hello someone of you managed to send data from 123solar and metern to home assistant, for example via mqtt?

Posts: 1

Participants: 1

Read full topic

Ways of `mimicking` standard Lovelace elements in custom cards (like button-card), anyone?

$
0
0

@AhmadK wrote:

Hi All,

I played for some time with a great custom button-card creating a card for my ventilation config.
What I noticed was the difference between font sizes Lovelace and button-card use to display entity’s name, for example:
Screen Shot 2020-03-31 at 07.39.15 (2)

and here’s the config

type: entities
entities:
  - type: custom:button-card
    entity: input_number.ventilation_1st_floor_bathroom_shower_humidity_gradient_threshold
    show_icon: false
  - entity: input_number.ventilation_1st_floor_bathroom_shower_temperature_gradient_threshold

As I wanted to have both standard and custom cards mixed within the Entities card, my goal was to have that “if greater than” string look the same in both input_number and button-card.
In fact, it was a bit bigger - as I use button-card and card-mod anyway, I wanted my custom card to look as close to standard Lovelace card as possible in terms of fonts and colours used (and it’s not limited by input_number, it’s just an example here).
And as it’s custom, it would allow to change it to something different as well (like font size of input_boolean's input field) :wink:

To achieve my goal I created several input_text sensor that hold default values for font size and color:

ventilation_ll_auto_settings_font_size:
  initial: '14px'

ventilation_ll_auto_settings_color:
  initial: 'var(--primary-text-color)'

ventilation_ll_auto_settings_input_width:
  initial: '3rem'

and then I use them to create some button-card templates

var_const_states:
  variables:
    invalid_states: ['unknown', 'unavailable']
    
base_row:
  template: var_const_states
  variables:
    margin_left: 0

    current_font_size_entity_id: 'input_text.font_size'
    default_font_size: 'var(--paper-input-container-shared-input-style_-_font-size)'

  styles:
    card:
      # set space between input field and name
      - margin-left: >-
          [[[ return variables.margin_left ]]]
      - margin-right: 3px
    # set standard font size and color
    name:
      - font-size: >-
          [[[
            var val = states[variables.current_font_size_entity_id];
            if (val === null || val.state === null || variables.invalid_states.includes(val.state)) return variables.default_font_size;
            return val.state;
          ]]]

As you can see, it pulls data from input_text and falls back to variables (overcomplicating things?)
And the beauty of using input_boolean here is that it can be accessed from any templateable card (like card-mod)/script and exposed in UI so one can change parameters on the fly/call set_value from an automation and voila, your card picks up changes immediately (well, at least button-card does).

So if I use that base_row as a template, I get a better result
Screen Shot 2020-03-31 at 07.42.20 (2)

Currently the step I’m missing is how to initialise that input_texts so they hold current (or default) Lovelace values? I.e instead of setting initial (which will reset them on every HA restart) I’d prefer to pull it from Lovelace.

It might be possible to do so from within button-card, for example, as it allows to execute Javascript code so things like querySelector can be used (I can grab font-size of “html”) but I’m not a web designer and at the moment it looks like it would be difficult to dive into shadow DOM to find that information - happy to be wrong here, please show me how!

tl/dr is there any way to store attributes’ values Lovelace uses to display its elements in input_text apart from hard coding them? I had an informative discussion with @RomRider about it, but maybe people like @Bram_Kragten, @thomasloven, @iantrich, @petro or anyone else knowledgeable (I believe there are many of them here) can chime in and guide me a little bit? :wink:

Thanks for reading.

p.s There is a good source of default values here, which I’ll hard code if there is no other option.

Posts: 4

Participants: 2

Read full topic


Lovelace Mini Graph Card scale

$
0
0

@cb24nz wrote:

Possible to have the scale starting at 0 rather than the lowest value ?
Have a range, if its a percent then be 0 to 100, If its something like temp then have the scale 0 to 40C

graph

Posts: 2

Participants: 2

Read full topic

Strange DB behaviour since v107 or Supervisor 214

$
0
0

@klogg wrote:

Has anyone else noticed that two files are constantly created and deleted since either v107 or Supervisor 214?

image

the files…

home-assistant_v2.db-shm and
home-assistant_v2.db-wal

…are appearing and disappearing every few seconds in my VS Code.

Does anyone know why?

This is not in itself a problem except if you want to create a new file or rename an existing one, because every time the display refreshes with the new or removed db files the file name box you are trying to type in loses focus.

Posts: 5

Participants: 2

Read full topic

Move lovelace tabs up beside header - custom js

$
0
0

@Da9L wrote:

I want to move my lovelace tabs up beside the title , and to do that i can use som simple javascript to get the following result:

Now i just wan to make the javascript load by it self everytime the page is loaded. What is the best practise for this in Home Assistant?

Posts: 2

Participants: 2

Read full topic

Problem with templating in automation action

$
0
0

@Greytooth wrote:

I’m trying to make some automations for a utility meter. I use different input_numers to keep values persistent and at certain times I want to reset the different input_numbers. My idea was to use an automation that triggers once a day and then use templating to reset certain values once a day, once a month and once a year. But my automation doesn’t work, the values doesn’t reset.

This is the code for my automation:

- alias: Energy - Reset input_numbers 
  initial_state: on
  trigger:
    platform: time
    at: "0:00:03"
  action:
    - service: input_number.set_value
      data_template:
        entity_id: >-
          {% if now().month == 1 and now().day == 1 %}
            - input_number.energy_daily
            - input_number.energy_monthly
            - input_number.energy_yearly
          {% elif now().day == 1 %}
            - input_number.energy_daily
            - input_number.energy_monthly
          {% else %}
            - input_number.energy_daily
          {% endif %}
        value: '0'

Can someone please tell me what is wrong with my code?

Posts: 6

Participants: 3

Read full topic

What's the simplest and cheapest reliable Zigbee for Hass?

$
0
0

@Mastiff wrote:

I need Zigbee to integrate with a lock (simple lock/unlock commands). What would the simplest and cheapest way of doing this be with Hass and a Pi, while still reliable?

Posts: 5

Participants: 3

Read full topic

Viewing all 106193 articles
Browse latest View live


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