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

mrb13676

Active Member
Joined
Sep 30, 2007
Messages
90
Arg, for some reason when I want to even just look at my yaml setup which I access using Studio Code Server, my RPi becomes unavailable and I cannot access it via IP address, URL, etc. Has anyone else experienced this before?
I had similar when I was on the Rpi. The only way around it for me was to directly edit the .yaml files via Studio Code Desktop over the network - i.e mounting the Pi in Finder (OSX)
 

Neuk_

Executive Member
Joined
Jan 23, 2018
Messages
6,663
I had similar when I was on the Rpi. The only way around it for me was to directly edit the .yaml files via Studio Code Desktop over the network - i.e mounting the Pi in Finder (OSX)

Arg :confused: Not what I wanted to hear but I'll try your method.
 

Neuk_

Executive Member
Joined
Jan 23, 2018
Messages
6,663
I had similar when I was on the Rpi. The only way around it for me was to directly edit the .yaml files via Studio Code Desktop over the network - i.e mounting the Pi in Finder (OSX)

Managed to get this to work using the Samba addon and access using my RPi's IP address, thanks ;)
 

w1tw0lf

Expert Member
Joined
Sep 29, 2009
Messages
1,083
Have to say it was the best move to run it as a VM on an old 2015 HP SFF PC (I bumped memory to 16GB) as it is faster and also don't need to worry about SD card wear.

That HP is now also my Plex Server and cloud clone server (OneDrive, GDrive, iCloud) - so it keeps a copy of everything (with it's own 2 week snapshot - just in case)

I snapshot my VM every few days (automated process) which get's uploaded to OneDrive and then downloaded on my other laptop (an even older 2010 spec i7 laptop)- in case I need to run from there if the main PC dies . The VM backup has saved me three times, already to recover from . I've had HASS updates bork the installation - and it's just been so easy to restore the VM again to 'roll-back' instead of trying to troubleshoot.

All these things run 24x7 unless like today, Eskom shares it's love with us.

Doing something similar with proxmox and having a daily backup of the vm has saved me this morning with 2022.2 update date something went wrong and broke all my sensors. Restored vm, run update and all sorted now.

My proxmox is an old i3 gen 3 with 16gb ram and SSD, running smoothly with few vm's, mostly just Debian servers each with their own task.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,358
Also using proxmox with vms that backup to a synology nas.

However 2022.02 update went smooth for me.
 

ebendl

Expert Member
Joined
Sep 27, 2004
Messages
4,599
I use Backups in HA which stores four days worth of backups on the RPi memory card and in my Google Drive and it has saved me already with updates gone wrong. I'll be looking at better but still small solution to the RPi, I don't really have the need for a full on server or probably even a VM.
Agreed, this is super necessary.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,358
Holy mackeroons.

2022.2 added zone bypass switches for the envisalink. Woo-hoo.
 

Vades

Well-Known Member
Joined
Apr 30, 2020
Messages
286
With loadshedding back in our lives I've now realised that my smart lights are not returning to their pre-power cut state when electricity is restored.

I have a group for outside lights, automated using the sun as a trigger. When electricity is restored at night, these remain off.

I have lights inside which are off when we're asleep. These turn on when power is restored.

Do I look at settings in the native apps or should I be adjusting something in HA itself?
 

ebendl

Expert Member
Joined
Sep 27, 2004
Messages
4,599
With loadshedding back in our lives I've now realised that my smart lights are not returning to their pre-power cut state when electricity is restored.

I have a group for outside lights, automated using the sun as a trigger. When electricity is restored at night, these remain off.

I have lights inside which are off when we're asleep. These turn on when power is restored.

Do I look at settings in the native apps or should I be adjusting something in HA itself?

What lights are they? Some do have a setting that remembers in their flash memory whether the light should remember it's state when it loses power (or alternatively default to on/off).

Before I had a PV/inverter system, my Home Assistant used to be killed with loadshedding too (not a great idea if you're running it on a Pi with Flash memory, btw). So I set it up to start automatically when power came back on, then I did an automation which triggered on HA startup which checked what state the lights (esp the outside ones) should be and turned them on.

Usually something like "at HA startup, if the sun is down, turn on outside lights".

I eventually moved the Pi over to a backup battery, then used the availability of some of my smart switches/smart lights as a proxy as to whether there was power or not. And then same thing - if the light become available again, assume that means power was restored and then run that same automation.
 

Vades

Well-Known Member
Joined
Apr 30, 2020
Messages
286
What lights are they? Some do have a setting that remembers in their flash memory whether the light should remember it's state when it loses power (or alternatively default to on/off).

Before I had a PV/inverter system, my Home Assistant used to be killed with loadshedding too (not a great idea if you're running it on a Pi with Flash memory, btw). So I set it up to start automatically when power came back on, then I did an automation which triggered on HA startup which checked what state the lights (esp the outside ones) should be and turned them on.

Usually something like "at HA startup, if the sun is down, turn on outside lights".

I eventually moved the Pi over to a backup battery, then used the availability of some of my smart switches/smart lights as a proxy as to whether there was power or not. And then same thing - if the light become available again, assume that means power was restored and then run that same automation.
Thanks, outside are regular lights with Shelly 1's. Inside, a combination of Bneta wifi downlights and regular lights, regular lights also on Shelly 1's.

HA is on a Nuc, connected to an inverter so it is always on.
 

ebendl

Expert Member
Joined
Sep 27, 2004
Messages
4,599
You would probably be able to set up power-on defaults on the apps.

But I would also - if you don't have something like it already - look at adding a sensor to see if your house has power or not. It is super useful to be able to get a notification that your power went out or came back on. And then you could use that to automate the lights, especially at night.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,358
With loadshedding back in our lives I've now realised that my smart lights are not returning to their pre-power cut state when electricity is restored.

I have a group for outside lights, automated using the sun as a trigger. When electricity is restored at night, these remain off.

I have lights inside which are off when we're asleep. These turn on when power is restored.

Do I look at settings in the native apps or should I be adjusting something in HA itself?
You can check app settings.
Shellies you can configure on the web interface, what their state should be after power loss.
Bneta is a hit/miss in the tuya app. If flashed to tasmota there is a setting on the web interface.

For HA automations, I went overboard to fix this issue you have. I literally have an automation running every minute checking light states, or rather, just setting them to the state they should be.

See: https://github.com/tinuva/home-assi...e5c7503fa/packages/lights/lights_outside.yaml

2 samples:
Code:
automation:
  ## Whole night
  - alias: "Turn on outside lights and check every minute - whole night"
    trigger:
      - platform: time_pattern
        # You can also match on interval. This will match every x minutes
        minutes: "/1"
    condition:
      condition: or
      conditions:
        - condition: sun
          after: sunset
          #after_offset: "00:20:00"
        - condition: sun
          before: sunrise
          #before_offset: "-00:20:00"
    action:
      - service: light.turn_on
        entity_id: 
          - light.lights_whole_night
  ## Whole day
  - alias: "Turn off outside lights and check every minute - whole night"
    trigger:
      - platform: time_pattern
        # You can also match on interval. This will match every x minutes
        minutes: "/1"
    condition:
      condition: and
      conditions:
        - condition: sun
          after: sunrise
          #after_offset: "-00:20:00"
        - condition: sun
          before: sunset
          #before_offset: "00:20:00"
    action:
      - service: light.turn_off
        entity_id: 
          - light.lights_whole_night
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
3,815
With loadshedding back in our lives I've now realised that my smart lights are not returning to their pre-power cut state when electricity is restored.

I have a group for outside lights, automated using the sun as a trigger. When electricity is restored at night, these remain off.

I have lights inside which are off when we're asleep. These turn on when power is restored.

Do I look at settings in the native apps or should I be adjusting something in HA itself?
I use NodeRed for scheduling lights, and the Light Scheduler node has an option to check on startup whether the light should be on or off. There are some other methods in NodeRed that can also be used for this on startup, depending on what you are doing.
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
3,815
I have a problem with a Sonoff TH16 with the temperature and humidity sensor. It has been working perfectly for many months, but last week our fibre was down for a couple of days due to a line break. Since then the temperature and humidity values do not get registered in Home Assistant anymore. I am using the SonoffLAN module, and previously only had the Ewelink username and password in my config. I have tried adding all the new parameters that are available (force_update, scan_interval, sensors) but the values just show as unknown in HA. My POW R2 reports the voltage, power and current just as before. The values are available in the Ewelink app so the sensor is still working. Any idea how to get the values back in HA?

Edit: I also update everything to the latest version but still no values coming in.
 

Vades

Well-Known Member
Joined
Apr 30, 2020
Messages
286
You can check app settings.
Shellies you can configure on the web interface, what their state should be after power loss.
Bneta is a hit/miss in the tuya app. If flashed to tasmota there is a setting on the web interface.

For HA automations, I went overboard to fix this issue you have. I literally have an automation running every minute checking light states, or rather, just setting them to the state they should be.

See: https://github.com/tinuva/home-assi...e5c7503fa/packages/lights/lights_outside.yaml

2 samples:
Code:
automation:
  ## Whole night
  - alias: "Turn on outside lights and check every minute - whole night"
    trigger:
      - platform: time_pattern
        # You can also match on interval. This will match every x minutes
        minutes: "/1"
    condition:
      condition: or
      conditions:
        - condition: sun
          after: sunset
          #after_offset: "00:20:00"
        - condition: sun
          before: sunrise
          #before_offset: "-00:20:00"
    action:
      - service: light.turn_on
        entity_id:
          - light.lights_whole_night
  ## Whole day
  - alias: "Turn off outside lights and check every minute - whole night"
    trigger:
      - platform: time_pattern
        # You can also match on interval. This will match every x minutes
        minutes: "/1"
    condition:
      condition: and
      conditions:
        - condition: sun
          after: sunrise
          #after_offset: "-00:20:00"
        - condition: sun
          before: sunset
          #before_offset: "00:20:00"
    action:
      - service: light.turn_off
        entity_id:
          - light.lights_whole_night

Thanks Tinuva, will take a deeper look this weekend. I've adjusted the power state settings in the Shelly app for the light relays. Tuya, seems to be set but the app is not great.
 

furpile

Expert Member
Joined
Jul 14, 2014
Messages
3,815
I have a problem with a Sonoff TH16 with the temperature and humidity sensor. It has been working perfectly for many months, but last week our fibre was down for a couple of days due to a line break. Since then the temperature and humidity values do not get registered in Home Assistant anymore. I am using the SonoffLAN module, and previously only had the Ewelink username and password in my config. I have tried adding all the new parameters that are available (force_update, scan_interval, sensors) but the values just show as unknown in HA. My POW R2 reports the voltage, power and current just as before. The values are available in the Ewelink app so the sensor is still working. Any idea how to get the values back in HA?

Edit: I also update everything to the latest version but still no values coming in.
Figured out my HACS is not working. I see these errors in the logs:
Code:
Platform hacs does not generate unique IDs. ID 0717a0cd-745c-48fd-9b16-c8534c9704f9-bc944b0f-fd42-4a58-a072-********** already exists - ignoring sensor.hacs
11:08:09 AM – (ERROR) Sensor
Bad credentials
11:08:09 AM – (ERROR) HACS (custom integration)
HACS is disabled - HacsDisabledReason.INVALID_TOKEN
11:08:09 AM – (ERROR) HACS (custom integration)

I generated a new token but it is still giving the same issue. Tried adding scopes to the token but still can't get it working (unless I don't have the correct scope selected). I see the new method is to register the device on github, but I can't get HACS to give me the token for that, will probably need to reinstall it?
 

w1tw0lf

Expert Member
Joined
Sep 29, 2009
Messages
1,083
I would say the easiest would be to remove HACS and reinstall it. Just follow the guide for uninstalling and installing it again.
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
39,583
So, I've blown another Sonoff POW2 with my well point pump and load shedding, I can now 100% confirm its related to load shedding.

Is there anyway to prevent this? Pump is 1.1kw.

Thinking of running it via a relay, but what's to stop the relay from going?

The Sonoff is always set to Off after Power reset, but - they still blow.
 

deesef

Expert Member
Joined
Mar 3, 2017
Messages
2,257
So, I've blown another Sonoff POW2 with my well point pump and load shedding, I can now 100% confirm its related to load shedding.

Is there anyway to prevent this? Pump is 1.1kw.

Thinking of running it via a relay, but what's to stop the relay from going?

The Sonoff is always set to Off after Power reset, but - they still blow.
Is the relay contact burning, or have the electronics failed?
 
Top