chomupashchuk/ariston-remotethermo-api

Not sure if it's working, need some help

Closed this issue · 4 comments

Hi, First of all, thanks for spending time on this.

I want to create my own control panel to display data from ariston-net.remotethermo.com. And I'm trying to gather this data using your API. But I'm having problems with basics. For example, getting the outside temp or water temperature. Maybe I'm not initializing the API session properly, or maybe amb not doing the request in a proper way.

Something basic:

from aristonremotethermo.ariston import AristonHandler

ApiInstance = AristonHandler(
    username='**********************',
    password='**********************',
    logging_level="DEBUG",
)

def get_temp(ApiInstance):

    ApiInstance.start()
    status = data = ApiInstance.available
    data = ApiInstance.sensor_values

    print(status)
    print(data["ch_water_temperature"])
    print(data["outside_temperature"])

    ApiInstance.stop()
    
get_temp(ApiInstance)

The response:

2021-11-06 18:30:33,839 - aristonremotethermo.ariston - INFO - API initiated
2021-11-06 18:30:33,839 - aristonremotethermo.ariston - INFO - Connection started
False
{'value': None, 'units': '°C'}
{'value': None, 'units': '°C'}
2021-11-06 18:30:33,839 - aristonremotethermo.ariston - INFO - Connection stopped

What I'm missing? Both sensors are available, I can see this data in www.ariston-net.remotethermo.com...

Can you please provide a simple example on "how-to" make a simple data request with your API?

Thanks!
Adrian

In general it works in a way that "start()" starts communication with the server. It sends multiple requests to fetch the data and it is being fetched periodically (timing was set during tests to have as little fails as possible as with high requests frequency boilers stopped responding, and thus polling rate was introduced to extend time for specific users if they encounter too many errors). Method "stop()" stops all the communication to the server. So in order to have some data you should simply wait. Also you must provide sensors in a list, for which you would like to have data (it is done this way as some boilers support some sensors and others simply crash if specific sensors are used and I have no idea how to automate such detection properly as there is no documentation. Also selected sensors indicate which requests API should use, as lesser requests - lesser loop of requests meaning higher frequency update).

For internal tests I have something like:

from aristonremotethermo.ariston import AristonHandler
import time

sensors = [
    'internet_weather',
    'dhw_economy_temperature',
    'holiday_mode',
    'water_last_24h_list',
    'dhw_flame',
    'heating_last_365d',
    'heating_last_365d_list',
    'water_last_7d',
    'water_last_30d',
    'heating_last_24h',
    'update',
    'heating_last_30d',
    'heat_pump',
    'water_last_24h',
    'ch_flame',
    'water_last_7d_list',
    'ch_detected_temperature',
    'dhw_thermal_cleanse_cycle',
    'dhw_thermal_cleanse_function',
    # 'online_version',
    'electricity_cost',
    'mode',
    'ch_comfort_temperature',
    'gas_type',
    'errors_count',
    'signal_strength',
    'dhw_storage_temperature',
    'ch_auto_function',
    'water_last_30d_list',
    'dhw_set_temperature',
    'ch_set_temperature',
    'ch_pilot',
    'errors',
    'ch_antifreeze_temperature',
    'ch_program',
    'account_dhw_electricity',
    'dhw_comfort_temperature',
    'ch_mode',
    'internet_time',
    # 'units',
    'account_dhw_gas',
    'flame',
    'account_ch_gas',
    'heating_last_7d_list',
    'heating_last_7d',
    'heating_last_30d_list',
    'water_last_365d_list',
    'ch_economy_temperature',
    'outside_temperature',
    'gas_cost',
    'account_ch_electricity',
    'dhw_mode',
    'water_last_365d',
    'dhw_comfort_function',
    'dhw_program',
    'heating_last_24h_list',
    'cooling_last_24h',
    'cooling_last_7d',
    'cooling_last_30d',
    'cooling_last_365d',
    'cooling_last_24h_list',
    'cooling_last_7d_list',
    'cooling_last_30d_list',
    'cooling_last_365d_list',
    # 'ch_water_temperature'
]

# help(AristonHandler)

version, sensors_get, sensors_set = AristonHandler.api_data()
print(version)
print(sensors_get)
print(sensors_set)

api = AristonHandler(
    username='***********************',
    password='***********************',
    sensors=sensors,
    units='metric',
    store_file=True,
    logging_level="DEBUG",
)

api.start()

And then depending on option I would like:
just print values of sensors periodically (api keeps the values, so it is how often application asks the api):

# Gather data for 300 seconds every 30 seconds
for i in range(10):
    print(api.sensor_values)
    time.sleep(30)

Another option I tested is subscription based functionality. I was asked to add it for MQTT (someone else was working on MQTT part) that your application subscribes and provides callback functions (in this case in sensors_updated and status_updated) to inform that API got new values for specific sensors as dictionary:

def sensors_updated(sensors, *args, **kwargs):
    print("*** Sensors were updated")
    print(f"*** Sensors are: {sensors}")


def status_updated(statuses, *args, **kwargs):
    print(f"*** Statuses were updated")
    print(f"*** Statuses are: {statuses}")

api.subscribe_sensors(sensors_updated)

api.subscribe_statuses(status_updated)

# gather data for 300 seconds before stop
time.sleep(300)

and during test I do stop the execution (in Home Assistant for home automation api is started and never stopped):

api.stop()

There is no functionality to simply get request for one sensor once, API was written to continiously monitor the sensors in the background, reestablish connection etc. I use it in Home Assistant to set different temparetures depending on time of day and my location, and additionally display the latest values, which were fetched by API. So to have data for specific sensor you might read sensors statuses periodically or use callback function and filter out from the dictionary the sensor you are interested in.

Hi, Thanks for your quick response!

I have tested your example, and it seems to work fine. Mission accomplished!

However, the API response shows that on most sensors I have no data. This is probably because my boiler is an Ariston Class One 24 model, and possibly it does not have these sensors installed. Even so, it is perfect for me to integrate the information with other home automation systems that I have.

I think your API has a lot of potential. But you need to improve the documentation with examples. I think the API should work as a method to get and post data for each sensor, like endpoint. This would allow to use the code in a more open way, so that it can be integrated with all kinds of systems. It's a recommendation, it took me a bit to understand how it works.

Anyway, thank you very much for helping me.

Kind Regards,
Adrian

The only reason I've created it was to control my boiler from Home Assistant. I've already spent hundreds of hours on it in order to make it work with multiple boilers for other people and become more stable. Since I do not get payed for it or any other project on Github, for which I do get new issues and feature requests that takes my personal time, I do not want to invest more of my time on it to write more detailed documentation (it does take time to think of use cases and what and how to describe) or adding new functions, which either might take much of my time or I see very few use cases for (e.g. potential 1-2 users). So new functions suggestions can be described in dedicated tickets, but there are no guarantees about any implementations.