-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear display values if nothing recieved #88
Comments
There is no out of the box way in ESPHome. But it could be added either via a script or into this component. The idea is you have a script which sets a flag: script:
- id: victron_present_reset
then:
- delay: 60s
- globals.set:
id: victron_present
value: 'false'
globals:
- id: victron_present
type: bool
restore_value: false
initial_value: 'false' And in the on_message event you reset it. victron_ble:
- id: MySmartShunt
mac_address: ${smart_shunt_mac_address}
bindkey: ${smart_shunt_encryption_key}
on_message:
then:
- lambda: |-
id(victron_present) = true;
id(victron_present_reset).stop();
id(victron_present_reset).execute(); And in the display you check the global variable: if (!id(victron_present)) {
// Victron device stale
} else {
// Victron device fresh
} |
Awesome thanks, I'll give it a whirl, I think I understand the first 3 bits, but I am not sure on how to use the display bit, does it go straight after (below) |
The third bit is in the individual display elements. E.g. Instead of: // shunt_AUX_VOLTAGE
it.printf(x1i, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F010C"); // mdi-car-battery
if (!std::isnan(id(shunt_AUX_VOLTAGE).state)) {
it.printf(x1i + icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%.2f V", id(shunt_AUX_VOLTAGE).state);
} You add the victron_present validation: // shunt_AUX_VOLTAGE
it.printf(x1i, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F010C"); // mdi-car-battery
if (!std::isnan(id(shunt_AUX_VOLTAGE).state) && id(victron_present)) {
it.printf(x1i + icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%.2f V", id(shunt_AUX_VOLTAGE).state);
} So then the number is only displayed if some value is there and it is not stale. |
Thank you so much for that! But, I haven't added this anywhere..? if (!id(victron_present)) { |
This part is a simpler version of the other. if (id(victron_present)) {
if (!std::isnan(id(shunt_AUX_VOLTAGE).state)) {
it.printf(x1i + icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%.2f V", id(shunt_AUX_VOLTAGE).state);
}
} |
This is awesome, love your work!
I was wondering though, it may be simple and something I just haven't discovered / learnt.
If say we went out of bluetooth range, could the values displayed go blank until new values are received?
The text was updated successfully, but these errors were encountered: