diff options
| author | diogo464 <[email protected]> | 2025-12-13 20:09:33 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-13 20:09:33 +0000 |
| commit | b456db36b7d973154f0a10bc1adca235de2c5c12 (patch) | |
| tree | 70a969b3c46710a86a57f07b59d5b9d863868be6 /src | |
| parent | e041614b0607a0950be1446f595d85c93b501418 (diff) | |
publish values on first iteration of run
if the connection fails its possible some value that needed to be
published did not get published so this should fix that.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 14 |
1 files changed, 9 insertions, 5 deletions
| @@ -863,6 +863,7 @@ pub async fn run<T: Transport>(device: &mut Device<'_>, transport: &mut T) -> Re | |||
| 863 | } | 863 | } |
| 864 | } | 864 | } |
| 865 | 865 | ||
| 866 | let mut first_iteration_push = true; | ||
| 866 | 'outer_loop: loop { | 867 | 'outer_loop: loop { |
| 867 | use core::fmt::Write; | 868 | use core::fmt::Write; |
| 868 | 869 | ||
| @@ -874,7 +875,7 @@ pub async fn run<T: Transport>(device: &mut Device<'_>, transport: &mut T) -> Re | |||
| 874 | None => break, | 875 | None => break, |
| 875 | }; | 876 | }; |
| 876 | 877 | ||
| 877 | if !entity.publish { | 878 | if !entity.publish && !first_iteration_push { |
| 878 | continue; | 879 | continue; |
| 879 | } | 880 | } |
| 880 | 881 | ||
| @@ -920,10 +921,12 @@ pub async fn run<T: Transport>(device: &mut Device<'_>, transport: &mut T) -> Re | |||
| 920 | device.publish_buffer.truncate(n); | 921 | device.publish_buffer.truncate(n); |
| 921 | } | 922 | } |
| 922 | _ => { | 923 | _ => { |
| 923 | crate::log::warn!( | 924 | if !first_iteration_push { |
| 924 | "entity '{}' requested state publish but its storage does not support it", | 925 | crate::log::warn!( |
| 925 | entity.config.id | 926 | "entity '{}' requested state publish but its storage does not support it", |
| 926 | ); | 927 | entity.config.id |
| 928 | ); | ||
| 929 | } | ||
| 927 | continue; | 930 | continue; |
| 928 | } | 931 | } |
| 929 | } | 932 | } |
| @@ -970,6 +973,7 @@ pub async fn run<T: Transport>(device: &mut Device<'_>, transport: &mut T) -> Re | |||
| 970 | } | 973 | } |
| 971 | } | 974 | } |
| 972 | } | 975 | } |
| 976 | first_iteration_push = false; | ||
| 973 | 977 | ||
| 974 | let receive = client.receive(); | 978 | let receive = client.receive(); |
| 975 | let waker = wait_on_atomic_waker(device.waker); | 979 | let waker = wait_on_atomic_waker(device.waker); |
