pyecodevices-rt2

Get information from GCE Ecodevices RT2.


Keywords
pyecodevices_rt2
License
MIT
Install
pip install pyecodevices-rt2==1.0.2

Documentation

pyecodevices-rt2 - Python GCE Ecodevices RT2

Documentation Status Updates pre-commit Black Project Maintenance BuyMeCoffee
Get information from GCE Ecodevices RT2.

This work is originally developed for use with Home Assistant and the custom component ecodevices_rt2.

Features

# Example with indexes
from pyecodevices_rt2 import EcoDevicesRT2
ecodevices = EcoDevicesRT2('192.168.0.20','80',"mysuperapikey")
ecodevices.get('Index','All') # Get all indexes as JSON
ecodevices.get('Index','All','Index_TI1') # Get specific value
  • Define a simple object such as Counter, DigitalInput, EnOcean Switch or Sensor, Post and Sub-Post, Relay, SupplierIndex, Toroid, VirtualOutput, X4FP (Heaters), XTHL:
# Example with a Relay
from pyecodevices_rt2 import EcoDevicesRT2, Relay
ecodevices = EcoDevicesRT2('192.168.0.20','80',"mysuperapikey")
# Relay number 1
test = Relay(ecodevices, 1)
print("Current status: %r" % test.status)
test.off() # Change relay to off
test.on() # Change relay to on
test.toggle() # Invert relay status
test.status = True # Change relay to on
  • Play with cached variables. You can defined a maximum value (in milliseconds) during which you consider an API value do not need to be updated:
from pyecodevices_rt2 import EcoDevicesRT2

# Create the ecodevices object with a default "cached" value of 1s
ecodevices = EcoDevicesRT2('192.168.0.20','80',"mysuperapikey", cached_ms=1000)

print("# All Indexes")
print(ecodevices.get('Index','All')) # Call the API
print(ecodevices.get('Index','All')) # Do not call the API since the last value was retrieved less than 1s (1000ms) ago
print(ecodevices.get('Index','All',cached_ms=0)) # Force to call the API even if the last value was retrieved less than 1s (1000ms) ago

# For each property in other objects, you can call "get_PROPERTY(cached_ms=XX)"
# Example with Counter 1:
test = Counter(ecodevices, 1)
print("Current value: %d" % test.value) # Call the API
print("Current price: %d" % test.price) # Call the API
print("Current value: %d" % test.value) # Do not call the API since the last value was retrieved less than 1s (1000ms) ago
print("Current price: %d" % test.price) # Do not call the API since the last value was retrieved less than 1s (1000ms) ago
print("Current value: %d" % test.get_value()) # Do not call the API since the last value was retrieved less than 1s (1000ms) ago
print("Current price: %d" % test.get_price()) # Do not call the API since the last value was retrieved less than 1s (1000ms) ago
print("Current value: %d" % test.get_value(cached_ms=0)) # Force to call the API even if the last value was retrieved less than 1s (1000ms) ago
print("Current price: %d" % test.get_price(cached_ms=0)) # Force to call the API even if the last value was retrieved less than 1s (1000ms) ago
print("Current value: %d" % test.get_value(cached_ms=2000)) # Do not call the API if the last value was retrieved less than 2s (2000ms) ago
print("Current price: %d" % test.get_price(cached_ms=2000)) # Do not call the API if the last value was retrieved less than 2s (2000ms) ago

Credits

This work is inspired by the work of Aohzan.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.