Home Assistant : Q&A, Tips & Tricks, Your Configs

n00bster

Well-Known Member
Joined
Nov 25, 2008
Messages
171
@SAguy how did you configure the Gate Status inside home assistant. ? Can you maybe show your HA dashboard.

Are you just using open close? or all of it. Open, Close, Opening, Closing, Collision detected etc
 

AmazeBalls

Well-Known Member
Joined
Jul 13, 2013
Messages
132
Trying to create a template sensor for a power attribute on a sonoff pow. Currently using the entity card to see the power attribute but would like it as its own sensor in orer to use as an energy sensor via the Riemann sum helper (just found out about this helper and its a life changer). however cant get my template to work, get no errors when checking the config but an error after restarting shows the following under the log:

Invalid config for [template]: invalid template (TemplateSyntaxError: unexpected end of template, expected 'end of print statement'.) for dictionary value @ data['sensor'][0]['state']. Got "{{ state.attr('switch.sonoff_10013bf60d', 'power')". (See /config/configuration.yaml, line 43).

config.yaml is as follows- tried with and without unit of measuremeant and no changes, sensor wont show up

YAML:
template:
  - sensor:
      - name:  "josh_thermostat_power"
        unit_of_measurement: W
        device_class: energy
        value_template: "{{ state.attr('switch.sonoff_10013bf60d', 'power')"
 
Last edited:

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,474
Trying to create a template sensor for a power attribute on a sonoff pow. Currently using the entity card to see the power attribute but would like it as its own sensor in orer to use as an energy sensor via the Riemann sum helper (just found out about this helper and its a life changer). however cant get my template to work, get no errors when checking the config but an error after restarting shows the following under the log:

Invalid config for [template]: invalid template (TemplateSyntaxError: unexpected end of template, expected 'end of print statement'.) for dictionary value @ data['sensor'][0]['state']. Got "{{ state.attr('switch.sonoff_10013bf60d', 'power')". (See /config/configuration.yaml, line 43).

config.yaml is as follows- tried with and without unit of measuremeant and no changes, sensor wont show up

YAML:
template:
- sensor:
- name: "josh_thermostat_power"
unit_of_measurement: W
device_class: energy
value_template: "{{ state.attr('switch.sonoff_10013bf60d', 'power')"
It is exactly what it says.

Template value start with {{ and end without the closing of them. Eg. You need to add them. At the end.
 

AmazeBalls

Well-Known Member
Joined
Jul 13, 2013
Messages
132
It is exactly what it says.

Template value start with {{ and end without the closing of them. Eg. You need to add them. At the end.
thanks, that did the trick and sensor was picked up, but doesnt show any data and state is unavialable

YAML:
template:
  - sensor:
      - name: "josh_thermostat_power"
        unit_of_measurement: W
        device_class: energy
        value_template: "{{ state.attr('switch.sonoff_10013bf60d', 'power') }}"
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,474
thanks, that did the trick and sensor was picked up, but doesnt show any data and state is unavialable

YAML:
template:
  - sensor:
      - name: "josh_thermostat_power"
        unit_of_measurement: W
        device_class: energy
        value_template: "{{ state.attr('switch.sonoff_10013bf60d', 'power') }}"
copy/paste the template value into the developer tools in the template tab to test it.
 

AmazeBalls

Well-Known Member
Joined
Jul 13, 2013
Messages
132
Your use of state attribute in the template is incorrect, it should be:
YAML:
value_template: "{{ state_attr('switch.sonoff_10013bf60d', 'power') }}"
How so, i compared your suggested config to mine and looks the same?
 

AmazeBalls

Well-Known Member
Joined
Jul 13, 2013
Messages
132
made some progress, in the template editor i get a value finally with this output.

template:
- sensor:
- name: "josh_thermostat_power"
unit_of_measurement: "W"
value_template: "0.0"

However entity still shows as unavailable and error as folows on the logs:

Invalid config for [template]: [value_template] is an invalid option for [template]. Check: template->sensor->0->value_template. (See /config/configuration.yaml, line 43).

Hvae read something around entities that show 0 values but not sure how to resolve them.
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
4,283
made some progress, in the template editor i get a value finally with this output.

template:
- sensor:
- name: "josh_thermostat_power"
unit_of_measurement: "W"
value_template: "0.0"

However entity still shows as unavailable and error as folows on the logs:

Invalid config for [template]: [value_template] is an invalid option for [template]. Check: template->sensor->0->value_template. (See /config/configuration.yaml, line 43).

Hvae read something around entities that show 0 values but not sure how to resolve them.
Mine looks like this:
Code:
sensor:
- platform: template
sensors:
pool_power:
friendly_name: 'Pool Power'
unit_of_measurement: 'W'
value_template: "{{ state_attr('switch.sonoff_1000f4xxxx', 'power') }}"

Then use the utility meter to sum this per day or month.
 

AmazeBalls

Well-Known Member
Joined
Jul 13, 2013
Messages
132
Mine looks like this:
Code:
sensor:
- platform: template
sensors:
pool_power:
friendly_name: 'Pool Power'
unit_of_measurement: 'W'
value_template: "{{ state_attr('switch.sonoff_1000f4xxxx', 'power') }}"

Then use the utility meter to sum this per day or month.
thanks, tried to replicate it and changing the details but get a whole bunch of errors now, could also be indentation


Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. Got None extra keys not allowed @ data['josh_thermostat_power']. Got None extra keys not allowed @ data['unit_of_measurement']. Got 'W' extra keys not allowed @ data['value_template']. Got "{{ state_attr('switch.sonoff_10013bfxxxd', 'power') }}". (See ?, line ?).
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
4,283
thanks, tried to replicate it and changing the details but get a whole bunch of errors now, could also be indentation


Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. Got None extra keys not allowed @ data['josh_thermostat_power']. Got None extra keys not allowed @ data['unit_of_measurement']. Got 'W' extra keys not allowed @ data['value_template']. Got "{{ state_attr('switch.sonoff_10013bfxxxd', 'power') }}". (See ?, line ?).
Weird. Works like that for me.

Here is a screenshot of the YAML for the spacing. I am on the phone so not easy to copy.
ec5ff6fc846adf0b77cd8b7b270e34df.jpg
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
4,283
My home assistant is on version 2022.2.1 and latest is 2022.4.7. However the update doesn't work, it starts but then just goes back to the update screen with no errors shown or in the log. Anyone else have issues with this update?
 

Gielie01

Well-Known Member
Joined
Mar 16, 2018
Messages
130
My home assistant is on version 2022.2.1 and latest is 2022.4.7. However the update doesn't work, it starts but then just goes back to the update screen with no errors shown or in the log. Anyone else have issues with this update?
Ive had it happen on a test bench when not "keeping up" with updates.
Solutions was backup to google, do a fresh install and restore the backup.
 

TedLasso

Expert Member
Joined
Feb 23, 2016
Messages
3,757
FWIW, I updated my 2022.4.6 to 2022.4.7 and then Mosquito Broker 6.0.2 and Samba and everything (especially PAI (alarm integration for those that don't know) is still working.

Decided to do it, as my PC had just completed a backup of the HASS VM and I thought best time to try without doing backups inside HASS.

Microsoft and my ISP must hate me. I backup the VM to OneDrive and then my second PC downloads it (via OneDrive too). Creates a 62GB load on ISP line every 2 days!
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,474
FWIW, I updated my 2022.4.6 to 2022.4.7 and then Mosquito Broker 6.0.2 and Samba and everything (especially PAI (alarm integration for those that don't know) is still working.

Decided to do it, as my PC had just completed a backup of the HASS VM and I thought best time to try without doing backups inside HASS.

Microsoft and my ISP must hate me. I backup the VM to OneDrive and then my second PC downloads it (via OneDrive too). Creates a 62GB load on ISP line every 2 days!
62GB! Hectic.

Well, that is one of the reasons why I only backup my config files on github. See https://github.com/tinuva/home-assistant-config

In fact, I now added a step, that it actually tests my config against future updates.

Sadly only I can see the logs of the actions, eg at https://github.com/tinuva/home-assistant-config

But what is inside is the following.

1. config tested against stable:
Code:
Run version="stable"
ghcr.io/home-assistant/home-assistant:stable
Run matcher="/home/runner/work/_actions/frenck/action-home-assistant/v1.3/matcher.json"
Run docker run --rm \
2022.4.7
Testing configuration at /github/workspace/.
INFO:homeassistant.util.package:Attempting install of msmart==0.2.2

2. config tested against beta:
Code:
Run version="beta"
ghcr.io/home-assistant/home-assistant:beta
Run matcher="/home/runner/work/_actions/frenck/action-home-assistant/v1.3/matcher.json"
Run docker run --rm \
2022.5.0b3
Testing configuration at /github/workspace/.
INFO:homeassistant.util.package:Attempting install of msmart==0.2.2

3. config tested against dev:
Code:
Run version="dev"
ghcr.io/home-assistant/home-assistant:dev
Run matcher="/home/runner/work/_actions/frenck/action-home-assistant/v1.3/matcher.json"
Run docker run --rm \
2022.6.0.dev20220430
Testing configuration at /github/workspace/.
INFO:homeassistant.util.package:Attempting install of msmart==0.2.2

Obviously not fool proof, but it gives me a headsup. The only thing I lose, is the history on metrics, but then again give it a week and those are all back.

I also have my influxdb running on a separate vm so that is handled separately.
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
4,283
Anybody using dimmers in HA? What is recommended? I was planning to get the Sonoff dimmer but it is out of stock everywhere and one website said it is discontinued in SA die to loadshedding ( loss of power causes issues apparently). Next option is the Shelly dimmer, but it is over R600. Any other options?

Also, I was looking at the POW R3 with a 25A rating for the geyser, but it seems to also use the spring loaded clips for the wires that the R2 uses. Don't know why they don't just use screw terminals.
 

MidnightZA

Expert Member
Joined
Mar 9, 2013
Messages
2,452
FWIW, I updated my 2022.4.6 to 2022.4.7 and then Mosquito Broker 6.0.2 and Samba and everything (especially PAI (alarm integration for those that don't know) is still working.

Thanks. I was waiting a few days to see if any issues were reported before doing all 3 of those updates
 
Top