Closed mikechouto closed 3 months ago
@EricCorleone any option?
As far as I know, the "unknown" state only appears when you reboot your HA and no event has been reported yet, and it should be the empty value None
rather than the string "unknown".
I can change it to none
instead of unknown
but i'm sure that it not empty value in previous version of HA
I'm not sure if you are talking about frontend display, because when the state is None
, it will be displayed as "Unknown" on the frontend.
@niceboygithub @EricCorleone I've change the default value for the vibration sensor to none
and repush the branch.
Thanks
@niceboygithub @EricCorleone I've change the default value for the vibration sensor to
none
and repush the branch.Thanks
Sorry I forgot to mention that using the empty string ''
as the default value would be a better choice😂because it will be displayed completely blank on the frontend, which looks much better than "unknown" (which is none
in the code).
@niceboygithub @EricCorleone I've change the default value for the vibration sensor to
none
and repush the branch. ThanksSorry I forgot to mention that using the empty string
''
as the default value would be a better choice😂because it will be displayed completely blank on the frontend, which looks much better than "unknown" (which isnone
in the code).
Hi, sorry you might miss understood from my previous reply, when the state is none
HA can correctly display it and it wouldn't show unknown
please find the information in screenshot below. IMHO using a default state would be better than empty string as having a readable default state can bring more advantage when we write and maintain script/automation.
The default values might be able to be like none
for sensors, off
for switch... etc.
The None
I meant is not a string, but the empty value in python without quotation marks and the first letter is capital. It will be rendered as "unknown" on the frontend according to my last try. But I guess the string "unknown" also works according to your screenshot.
And the reason I prefer the empty string over "unknown" is simply because it looks better, but both are ok I guess (also I don't think I will use the empty/unknown state in automations).
Hey Eric yeah I've also tested the None
in python which will be render as unknown
on frontend. And I have some automation base on state changes so having a default value would let my automation be more readable LOL. I think we can wait for @niceboygithub to see what he would like the default value to be for long term usage, then i can modify. Thanks again for the detail explain.
Both ""
and "none"
are hardcoded. If I had to choose one, I'd choose ""
.
I searched the code history and found that it was always ""
. If you change this default, you might break other people's automation.
@Necroneco Thanks for pointing it out I've modify the branch to just moved reset_state
into GatewayBinarySensor
class and the function will always be ''
now.
But this is not much different from #280. Currently, only these two classes need this method.
@Necroneco I’m not sure if there are other devices that got effected as I don’d have a large variety to test against. And yeah merging both should be fine, I was just thinking to reduce duplicate code. ^_^
lumi.vibration.aq1
)reset_state
intoGatewayBinarySensor
class .Thank you @niceboygithub