ShellyRelay

class mtf.relays.shelly_controller.ShellyRelay

A class to control a Shelly relay via its RPC API.

Attributes:

base_url (str): The base URL for the Shelly relay API.

__init__(ip_address)

Initializes the ShellyRelay with the given IP address.

Args:

ip_address (str): The IP address of the Shelly relay.

turn_on()

Turns on the relay by sending a request to the Shelly API.

Prints a success message if the relay is turned on, otherwise prints an error message with details.

get_config()

Retrieves the configuration of the relay from the Shelly API.

Prints the configuration if the request is successful, otherwise prints an error message with details.

turn_off()

Turns off the relay by sending a request to the Shelly API.

Prints a success message if the relay is turned off, otherwise prints an error message with details.

get_status()

Retrieves the current status of the relay from the Shelly API.

Returns the status as a dictionary if successful, otherwise returns None and prints an error message with details.

Returns:

dict or None: The status of the relay or None if the request failed.