Skip to main content

ShellyClient

Struct ShellyClient 

Source
pub struct ShellyClient { /* private fields */ }
Expand description

Stateless switchkit::SmartDevice adapter for Shelly devices. No per-device state is kept here; every call re-opens the device (a cheap HTTP probe) so the adapter always reflects the device’s current generation and identity.

Implementations§

Source§

impl ShellyClient

Source

pub fn new() -> Self

Build a client with a bounded request timeout and connect timeout, so a dead or unreachable device fails fast instead of hanging a caller indefinitely.

Trait Implementations§

Source§

impl Default for ShellyClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl SmartDevice for ShellyClient

Source§

fn probe<'life0, 'life1, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, ) -> Pin<Box<dyn Future<Output = Result<Option<DeviceSnapshot>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reachable-but-not-Shelly (probe_target returning Error::Parse) maps to Ok(None), never a guessed vendor. Any other error (offline, auth, …) propagates as Err.

Source§

fn set_power<'life0, 'life1, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, channel: Option<u8>, action: PowerAction, ) -> Pin<Box<dyn Future<Output = Result<Relay>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Issues the power action, then reads back the CONFIRMED post-change state via switch_status rather than trusting SwitchResult.was_on (the previous state for Gen2’s Switch.Set/Switch.Toggle, with inconsistent semantics across generations).

Source§

fn firmware_update<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, _ota_url: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Shelly’s stable-channel OTA update takes no URL parameter; ota_url is accepted for trait compatibility but unused in v1.

Source§

fn config_get<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, setting: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Shelly has no single-setting GET; config is one blob. setting == "" returns the whole config. A non-empty setting returns that top-level key’s value when present; an absent key is Err(Rejected), never a fabricated null/{} (absent is not a value).

Source§

fn config_set<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, setting: &'life2 str, value: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Returns the device’s actual response to the settings write, never a fabricated {"ok":true}.

Source§

fn backup<'life0, 'life1, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

A Shelly config backup is its settings JSON, pretty-printed.

Source§

fn console<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, command: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Gen2/3 only: command is "Method [json-params]", passed through verbatim to the device’s JSON-RPC endpoint. Gen1 has no RPC console, so it is genuinely Unsupported, not an empty/guessed response.

Source§

fn vendor(&self) -> Vendor

Source§

fn status<'life0, 'life1, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, ) -> Pin<Box<dyn Future<Output = Result<DeviceSnapshot>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

One refresh. Ok = reachable reading; Err = unreadable (the consumer renders offline).
Source§

fn firmware_version<'life0, 'life1, 'async_trait>( &'life0 self, target: &'life1 DeviceTarget, ) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more