Package: pyecodevices-rt2
pyecodevices-rt2 - PythonGCE Ecodevices RT2Get information fromGCE Ecodevices RT2.This work is originally developed for use withHome Assistantand thecustom componentecodevices_rt2.Free software: MIT licenseDocumentation:https://pyecodevices-rt2.readthedocs.io.FeaturesConnect to the API (seeGCE Ecodevices RT2 API(orPDF)) and get any value:# Example with indexesfrompyecodevices_rt2importEcoDevicesRT2ecodevices=EcoDevicesRT2('192.168.0.20','80',"mysuperapikey")ecodevices.get('Index','All')# Get all indexes as JSONecodevices.get('Index','All','Index_TI1')# Get specific valueDefine a simple object such asCounter,DigitalInput,EnOcean Switch or Sensor,Post and Sub-Post,Relay,SupplierIndex,Toroid,VirtualOutput,X4FP (Heaters),XTHL:# Example with a Relayfrompyecodevices_rt2importEcoDevicesRT2,Relayecodevices=EcoDevicesRT2('192.168.0.20','80',"mysuperapikey")# Relay number 1test=Relay(ecodevices,1)print("Current status:%r"%test.status)test.off()# Change relay to offtest.on()# Change relay to ontest.toggle()# Invert relay statustest.status=True# Change relay to onPlay with cached variables. You can defined a maximum value (in milliseconds) during which you consider an API value do not need to be updated:frompyecodevices_rt2importEcoDevicesRT2# Create the ecodevices object with a default "cached" value of 1secodevices=EcoDevicesRT2('192.168.0.20','80',"mysuperapikey",cached_ms=1000)print("# All Indexes")print(ecodevices.get('Index','All'))# Call the APIprint(ecodevices.get('Index','All'))# Do not call the API since the last value was retrieved less than 1s (1000ms) agoprint(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 APIprint("Current price:%d"%test.price)# Call the APIprint("Current value:%d"%test.value)# Do not call the API since the last value was retrieved less than 1s (1000ms) agoprint("Current price:%d"%test.price)# Do not call the API since the last value was retrieved less than 1s (1000ms) agoprint("Current value:%d"%test.get_value())# Do not call the API since the last value was retrieved less than 1s (1000ms) agoprint("Current price:%d"%test.get_price())# Do not call the API since the last value was retrieved less than 1s (1000ms) agoprint("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) agoprint("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) agoprint("Current value:%d"%test.get_value(cached_ms=2000))# Do not call the API if the last value was retrieved less than 2s (2000ms) agoprint("Current price:%d"%test.get_price(cached_ms=2000))# Do not call the API if the last value was retrieved less than 2s (2000ms) agoCreditsThis work is inspired by the work ofAohzan.This package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History1.3.1 (2022-08-07)Add option with cached_ms<0 to force use the cache, or return None1.3.0 (2022-08-07)Update Toroid API, using new EcoRT2 version 3.00.021.2.1 (2021-05-15)Add “get_all_cached” function to call all resquests to get a cached value.1.2.0 (2021-05-14)Add “cached” possibilities to reduce the number of call to the API.The cached possibilities can be defined directly to the ecodevices_rt2 object (applicable to each call), or to a specific call on a property.1.1.0 (2021-04-17)Add classes such asCounter,DigitalInput,EnOcean Switch or Sensor,Post and Sub-Post,Relay,SupplierIndex,Toroid,VirtualOutput,X4FP (Heaters),XTHLfor ease of useAdd tests to cover majority of codeAdd full examples in documentation1.0.1 (2021-04-12)Update package withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.1.0.0 (2021-04-08)First release on PyPI.