iPhone Gauge Lockscreen Setup cant get it to work

I have been trying for days now to get the iPhone lock screen gauge to work. A few people on Facebook have been extremely helpful but still it wont display the entity state properly. All I get is a gauge with questions marks.
Can anyone help?

Currently I have the following script .
Value template (0-1)
{% set original = states(‘sensor.ioniq_5_ev_battery_level’) | float %}
{% set minimum = 0 %}
{% set maximum = 100 %}
{% set adjusted = min(maximum, max(minimum, original)) %}
{{ (adjusted - minimum) / (maximum - minimum) }}

Value Label template
{{states(‘sensor.ioniq_5_ev_battery_level’) }}

I’ve searched for any form of docs for the widget-on-lock-screen feature and didn’t find anything. Anyone?

In said Facebook group one user mentioned the similarity to complications, see Complications | Home Assistant Companion Docs

I’ve used

{% set original = states("sensor.batteries_state_of_capacity") | float %}
{% set minimum = 0.0 %}
{% set maximum = 100.0 %}
{% set adjusted = min(maximum, max(minimum, original)) %}
{{ (adjusted - minimum) / (maximum - minimum) }}

in the value template field, 0 for min label template, 100 for max label template and “Bat” for value lable template. Probably overkill for a percentage value, but it worked right away.

@mccltd maybe try 0.0 and 100.0 for min and max?

Thanks, do you have a screen shot of your script page you could share for the gauge

Go to your iPhones Lock Screen, add a gauge widget and edit it like so:

IMG_0307

In the above example it shows two gauges, one temp sensor and my PV battery’s level.

I have exactly that with my ev battery entity in but still it wont display anything other than a gauge with ? on.
Going to try another entity even thou it works fine in the developer tools test

Just tried with a different entity for my solar. Works perfectly in the dev tools template test but nothing on the phone gauge.

I just stumbled upon this functionality, and the code in post #2 is working for me to show my house battery state (Huawei Solar)

Gauge Type: Normal
Server: Home

Value template 0-1:

{% set original = states("sensor.battery_state_of_capacity") | float %}
{% set minimum = 0.0 %}
{% set maximum = 100.0 %}
{% set adjusted = min(maximum, max(minimum, original)) %}
{{ (adjusted - minimum) / (maximum - minimum) }}

Value Label Template: HouseBatt

Min Label Template: 0

Max Label Template: 100

thanks, still doesnt work for me.
Going to uninstall the HA app, reboot and add it again as I cannot see anything Im doing wrong.

After recent HA Companion app update, all of my lock screen HA widgets stopped to work (Unable to load). Perhaps there is some issue for you with that as weel. Can you try just action windet, or any other? BTW widgets load properly on home screen…

@mccltd Only other thing I can think of is for you to check if your home assistant components are at their latest level?

@mirekmal I have a similar issue, not sure how often these are supposed to update but it seems quite slow. Slow enough to be not terribly useful. Perhaps I’m using it wrong – I setup 3 widgets put my battery %age, house energy draw + solar production (both W). The last two values change very fast whereas the percentage does not.

I ended up with using it only for actions; that was convinient to have the readily available on the lock screen. Previously sooner or lated actions were available in the widget. Now, it is already copuple of days and still ‘unable to load’… I’d not call it delay… it just does not work at all :frowning:

For other rerason I had to restart my iPhone and magically widget started to show actions again! Perhaps this is the solution…