ESPHome  2022.11.3
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::shelly_dimmer::ShellyDimmer Class Reference

#include <shelly_dimmer.h>

Inheritance diagram for esphome::shelly_dimmer::ShellyDimmer:
esphome::PollingComponent esphome::light::LightOutput esphome::uart::UARTDevice esphome::Component

Public Member Functions

float get_setup_priority () const override
 
void setup () override
 
void update () override
 
void dump_config () override
 
light::LightTraits get_traits () override
 
void setup_state (light::LightState *state) override
 
void write_state (light::LightState *state) override
 
void set_nrst_pin (GPIOPin *nrst_pin)
 
void set_boot0_pin (GPIOPin *boot0_pin)
 
void set_leading_edge (bool leading_edge)
 
void set_warmup_brightness (uint16_t warmup_brightness)
 
void set_warmup_time (uint16_t warmup_time)
 
void set_fade_rate (uint16_t fade_rate)
 
void set_min_brightness (uint16_t min_brightness)
 
void set_max_brightness (uint16_t max_brightness)
 
void set_power_sensor (sensor::Sensor *power_sensor)
 
void set_voltage_sensor (sensor::Sensor *voltage_sensor)
 
void set_current_sensor (sensor::Sensor *current_sensor)
 
- Public Member Functions inherited from esphome::PollingComponent
 PollingComponent ()
 
 PollingComponent (uint32_t update_interval)
 Initialize this polling component with the given update interval in ms. More...
 
virtual void set_update_interval (uint32_t update_interval)
 Manually set the update interval in ms for this polling object. More...
 
void call_setup () override
 
virtual uint32_t get_update_interval () const
 Get the update interval in ms of this sensor. More...
 
- Public Member Functions inherited from esphome::Component
virtual void loop ()
 This method will be called repeatedly. More...
 
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
bool is_failed ()
 
virtual bool can_proceed ()
 
bool status_has_warning ()
 
bool status_has_error ()
 
void status_set_warning ()
 
void status_set_error ()
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
 
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...
 
- Public Member Functions inherited from esphome::light::LightOutput
virtual std::unique_ptr< LightTransformercreate_default_transition ()
 Return the default transformer used for transitions. More...
 
virtual void update_state (LightState *state)
 Called on every update of the current values of the associated LightState, can optionally be used to do processing of this change. More...
 
- Public Member Functions inherited from esphome::uart::UARTDevice
 UARTDevice ()=default
 
 UARTDevice (UARTComponent *parent)
 
void set_uart_parent (UARTComponent *parent)
 
void write_byte (uint8_t data)
 
void write_array (const uint8_t *data, size_t len)
 
void write_array (const std::vector< uint8_t > &data)
 
template<size_t N>
void write_array (const std::array< uint8_t, N > &data)
 
void write_str (const char *str)
 
bool read_byte (uint8_t *data)
 
bool peek_byte (uint8_t *data)
 
bool read_array (uint8_t *data, size_t len)
 
template<size_t N>
optional< std::array< uint8_t, N > > read_array ()
 
int available ()
 
void flush ()
 
int read ()
 
size_t write (uint8_t data)
 
int peek ()
 
void check_uart_settings (uint32_t baud_rate, uint8_t stop_bits=1, UARTParityOptions parity=UART_CONFIG_PARITY_NONE, uint8_t data_bits=8)
 Check that the configuration of the UART bus matches the provided values and otherwise print a warning. More...
 

Protected Member Functions

uint16_t convert_brightness_ (float brightness)
 Convert relative brightness into a dimmer brightness value. More...
 
void send_brightness_ (uint16_t brightness)
 Sends the given brightness value. More...
 
void send_settings_ ()
 Sends dimmer configuration. More...
 
bool upgrade_firmware_ ()
 Performs a firmware upgrade. More...
 
bool send_command_ (uint8_t cmd, const uint8_t *payload, uint8_t len)
 Sends a command and waits for an acknowledgement. More...
 
size_t frame_command_ (uint8_t *data, uint8_t cmd, const uint8_t *payload, size_t len)
 Frames a given command payload. More...
 
int handle_byte_ (uint8_t c)
 Handles a single byte as part of a protocol frame. More...
 
bool read_frame_ ()
 Reads a response frame. More...
 
bool handle_frame_ ()
 Handles a complete frame. More...
 
void reset_ (bool boot0)
 Reset STM32 with the BOOT0 pin set to the given value. More...
 
void reset_normal_boot_ ()
 Reset STM32 to boot the regular firmware. More...
 
void reset_dfu_boot_ ()
 Reset STM32 to boot into DFU mode to enable firmware upgrades. More...
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult()> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name. More...
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult()> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function. More...
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Protected Attributes

GPIOPinpin_nrst_
 
GPIOPinpin_boot0_
 
uint8_t seq_ {0}
 
std::array< uint8_t, SHELLY_DIMMER_BUFFER_SIZE > buffer_
 
uint8_t buffer_pos_ {0}
 
uint8_t version_major_
 
uint8_t version_minor_
 
bool leading_edge_ {false}
 
uint16_t warmup_brightness_ {100}
 
uint16_t warmup_time_ {20}
 
uint16_t fade_rate_ {0}
 
uint16_t min_brightness_ {0}
 
uint16_t max_brightness_ {1000}
 
light::LightStatestate_ {nullptr}
 
sensor::Sensorpower_sensor_ {nullptr}
 
sensor::Sensorvoltage_sensor_ {nullptr}
 
sensor::Sensorcurrent_sensor_ {nullptr}
 
bool ready_ {false}
 
uint16_t brightness_
 
- Protected Attributes inherited from esphome::PollingComponent
uint32_t update_interval_
 
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 
const char * component_source_ {nullptr}
 
- Protected Attributes inherited from esphome::uart::UARTDevice
UARTComponentparent_ {nullptr}
 

Detailed Description

Definition at line 14 of file shelly_dimmer.h.

Member Function Documentation

◆ convert_brightness_()

uint16_t esphome::shelly_dimmer::ShellyDimmer::convert_brightness_ ( float  brightness)
protected

Convert relative brightness into a dimmer brightness value.

Definition at line 211 of file shelly_dimmer.cpp.

◆ dump_config()

void esphome::shelly_dimmer::ShellyDimmer::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 115 of file shelly_dimmer.cpp.

◆ frame_command_()

size_t esphome::shelly_dimmer::ShellyDimmer::frame_command_ ( uint8_t *  data,
uint8_t  cmd,
const uint8_t *  payload,
size_t  len 
)
protected

Frames a given command payload.

Definition at line 295 of file shelly_dimmer.cpp.

◆ get_setup_priority()

float esphome::shelly_dimmer::ShellyDimmer::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 19 of file shelly_dimmer.h.

◆ get_traits()

light::LightTraits esphome::shelly_dimmer::ShellyDimmer::get_traits ( )
inlineoverridevirtual

Implements esphome::light::LightOutput.

Definition at line 25 of file shelly_dimmer.h.

◆ handle_byte_()

int esphome::shelly_dimmer::ShellyDimmer::handle_byte_ ( uint8_t  c)
protected

Handles a single byte as part of a protocol frame.

Returns -1 on failure, 0 when finished and 1 when more bytes needed.

Definition at line 318 of file shelly_dimmer.cpp.

◆ handle_frame_()

bool esphome::shelly_dimmer::ShellyDimmer::handle_frame_ ( )
protected

Handles a complete frame.

Definition at line 386 of file shelly_dimmer.cpp.

◆ read_frame_()

bool esphome::shelly_dimmer::ShellyDimmer::read_frame_ ( )
protected

Reads a response frame.

Definition at line 357 of file shelly_dimmer.cpp.

◆ reset_()

void esphome::shelly_dimmer::ShellyDimmer::reset_ ( bool  boot0)
protected

Reset STM32 with the BOOT0 pin set to the given value.

Definition at line 475 of file shelly_dimmer.cpp.

◆ reset_dfu_boot_()

void esphome::shelly_dimmer::ShellyDimmer::reset_dfu_boot_ ( )
protected

Reset STM32 to boot into DFU mode to enable firmware upgrades.

Definition at line 509 of file shelly_dimmer.cpp.

◆ reset_normal_boot_()

void esphome::shelly_dimmer::ShellyDimmer::reset_normal_boot_ ( )
protected

Reset STM32 to boot the regular firmware.

Definition at line 496 of file shelly_dimmer.cpp.

◆ send_brightness_()

void esphome::shelly_dimmer::ShellyDimmer::send_brightness_ ( uint16_t  brightness)
protected

Sends the given brightness value.

Definition at line 220 of file shelly_dimmer.cpp.

◆ send_command_()

bool esphome::shelly_dimmer::ShellyDimmer::send_command_ ( uint8_t  cmd,
const uint8_t *  payload,
uint8_t  len 
)
protected

Sends a command and waits for an acknowledgement.

Definition at line 268 of file shelly_dimmer.cpp.

◆ send_settings_()

void esphome::shelly_dimmer::ShellyDimmer::send_settings_ ( )
protected

Sends dimmer configuration.

Definition at line 233 of file shelly_dimmer.cpp.

◆ set_boot0_pin()

void esphome::shelly_dimmer::ShellyDimmer::set_boot0_pin ( GPIOPin boot0_pin)
inline

Definition at line 35 of file shelly_dimmer.h.

◆ set_current_sensor()

void esphome::shelly_dimmer::ShellyDimmer::set_current_sensor ( sensor::Sensor current_sensor)
inline

Definition at line 46 of file shelly_dimmer.h.

◆ set_fade_rate()

void esphome::shelly_dimmer::ShellyDimmer::set_fade_rate ( uint16_t  fade_rate)
inline

Definition at line 40 of file shelly_dimmer.h.

◆ set_leading_edge()

void esphome::shelly_dimmer::ShellyDimmer::set_leading_edge ( bool  leading_edge)
inline

Definition at line 37 of file shelly_dimmer.h.

◆ set_max_brightness()

void esphome::shelly_dimmer::ShellyDimmer::set_max_brightness ( uint16_t  max_brightness)
inline

Definition at line 42 of file shelly_dimmer.h.

◆ set_min_brightness()

void esphome::shelly_dimmer::ShellyDimmer::set_min_brightness ( uint16_t  min_brightness)
inline

Definition at line 41 of file shelly_dimmer.h.

◆ set_nrst_pin()

void esphome::shelly_dimmer::ShellyDimmer::set_nrst_pin ( GPIOPin nrst_pin)
inline

Definition at line 34 of file shelly_dimmer.h.

◆ set_power_sensor()

void esphome::shelly_dimmer::ShellyDimmer::set_power_sensor ( sensor::Sensor power_sensor)
inline

Definition at line 44 of file shelly_dimmer.h.

◆ set_voltage_sensor()

void esphome::shelly_dimmer::ShellyDimmer::set_voltage_sensor ( sensor::Sensor voltage_sensor)
inline

Definition at line 45 of file shelly_dimmer.h.

◆ set_warmup_brightness()

void esphome::shelly_dimmer::ShellyDimmer::set_warmup_brightness ( uint16_t  warmup_brightness)
inline

Definition at line 38 of file shelly_dimmer.h.

◆ set_warmup_time()

void esphome::shelly_dimmer::ShellyDimmer::set_warmup_time ( uint16_t  warmup_time)
inline

Definition at line 39 of file shelly_dimmer.h.

◆ setup()

void esphome::shelly_dimmer::ShellyDimmer::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 65 of file shelly_dimmer.cpp.

◆ setup_state()

void esphome::shelly_dimmer::ShellyDimmer::setup_state ( light::LightState state)
inlineoverridevirtual

Reimplemented from esphome::light::LightOutput.

Definition at line 31 of file shelly_dimmer.h.

◆ update()

void esphome::shelly_dimmer::ShellyDimmer::update ( )
overridevirtual

Implements esphome::PollingComponent.

Definition at line 113 of file shelly_dimmer.cpp.

◆ upgrade_firmware_()

bool esphome::shelly_dimmer::ShellyDimmer::upgrade_firmware_ ( )
protected

Performs a firmware upgrade.

Definition at line 157 of file shelly_dimmer.cpp.

◆ write_state()

void esphome::shelly_dimmer::ShellyDimmer::write_state ( light::LightState state)
overridevirtual

Implements esphome::light::LightOutput.

Definition at line 139 of file shelly_dimmer.cpp.

Field Documentation

◆ brightness_

uint16_t esphome::shelly_dimmer::ShellyDimmer::brightness_
protected

Definition at line 75 of file shelly_dimmer.h.

◆ buffer_

std::array<uint8_t, SHELLY_DIMMER_BUFFER_SIZE> esphome::shelly_dimmer::ShellyDimmer::buffer_
protected

Definition at line 54 of file shelly_dimmer.h.

◆ buffer_pos_

uint8_t esphome::shelly_dimmer::ShellyDimmer::buffer_pos_ {0}
protected

Definition at line 55 of file shelly_dimmer.h.

◆ current_sensor_

sensor::Sensor* esphome::shelly_dimmer::ShellyDimmer::current_sensor_ {nullptr}
protected

Definition at line 72 of file shelly_dimmer.h.

◆ fade_rate_

uint16_t esphome::shelly_dimmer::ShellyDimmer::fade_rate_ {0}
protected

Definition at line 65 of file shelly_dimmer.h.

◆ leading_edge_

bool esphome::shelly_dimmer::ShellyDimmer::leading_edge_ {false}
protected

Definition at line 62 of file shelly_dimmer.h.

◆ max_brightness_

uint16_t esphome::shelly_dimmer::ShellyDimmer::max_brightness_ {1000}
protected

Definition at line 67 of file shelly_dimmer.h.

◆ min_brightness_

uint16_t esphome::shelly_dimmer::ShellyDimmer::min_brightness_ {0}
protected

Definition at line 66 of file shelly_dimmer.h.

◆ pin_boot0_

GPIOPin* esphome::shelly_dimmer::ShellyDimmer::pin_boot0_
protected

Definition at line 50 of file shelly_dimmer.h.

◆ pin_nrst_

GPIOPin* esphome::shelly_dimmer::ShellyDimmer::pin_nrst_
protected

Definition at line 49 of file shelly_dimmer.h.

◆ power_sensor_

sensor::Sensor* esphome::shelly_dimmer::ShellyDimmer::power_sensor_ {nullptr}
protected

Definition at line 70 of file shelly_dimmer.h.

◆ ready_

bool esphome::shelly_dimmer::ShellyDimmer::ready_ {false}
protected

Definition at line 74 of file shelly_dimmer.h.

◆ seq_

uint8_t esphome::shelly_dimmer::ShellyDimmer::seq_ {0}
protected

Definition at line 53 of file shelly_dimmer.h.

◆ state_

light::LightState* esphome::shelly_dimmer::ShellyDimmer::state_ {nullptr}
protected

Definition at line 69 of file shelly_dimmer.h.

◆ version_major_

uint8_t esphome::shelly_dimmer::ShellyDimmer::version_major_
protected

Definition at line 58 of file shelly_dimmer.h.

◆ version_minor_

uint8_t esphome::shelly_dimmer::ShellyDimmer::version_minor_
protected

Definition at line 59 of file shelly_dimmer.h.

◆ voltage_sensor_

sensor::Sensor* esphome::shelly_dimmer::ShellyDimmer::voltage_sensor_ {nullptr}
protected

Definition at line 71 of file shelly_dimmer.h.

◆ warmup_brightness_

uint16_t esphome::shelly_dimmer::ShellyDimmer::warmup_brightness_ {100}
protected

Definition at line 63 of file shelly_dimmer.h.

◆ warmup_time_

uint16_t esphome::shelly_dimmer::ShellyDimmer::warmup_time_ {20}
protected

Definition at line 64 of file shelly_dimmer.h.


The documentation for this class was generated from the following files: