jnimmo / pyIntesisHome

Python interface for IntesisHome devices
MIT License
35 stars 20 forks source link

Possibility to use with Domoticz #3

Closed mvveelen closed 3 years ago

mvveelen commented 6 years ago

Could you add the possibility to use this with Domoticz? I was trying to figure out the api.cgi commands, but to no avail. Maybe you can help me (us ?) out.

gianfrdp commented 5 years ago

Hello, I use this script

#!/usr/bin/env python3.5

import time
import requests
from optparse import OptionParser
from pyintesishome import IntesisHome
import sys
import pycurl
import re
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
from datetime import datetime
try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO

def main():

    username="xxxxxxxxx"
    password="yyyyyyyyy"
    idd = zzzzzzz
    aquarea = None

    temp_idx = 18
    set_point_idx = 40

    aquarea = IntesisHome(username, password)
    aquarea.poll_status()

    today = datetime.today()
    tank_temp = aquarea.get_tank_temperature(idd)
    tank_set_point = aquarea._get_gen_value(idd,'tank_setpoint_temperature')
    wifi_signal = aquarea._get_gen_value(idd,'uid_60002')
    print(today.strftime("%Y-%m-%d %H:%M:%S: ") + "Tank temperature = %.1f°C, Tank set point = %.1f°C, WIFI signal = %d" % (tank_temp,tank_set_point,wifi_signal))

    if (wifi_signal > 0):
        msgs = [{'topic':"domoticz/in", 'payload':"{\"idx\":%d,\"nvalue\":0,\"svalue\":\"%s\"}" % (temp_idx, str(tank_temp))},
                ("domoticz/in", "{\"idx\":%d,\"nvalue\":0,\"svalue\":\"%s\"}" % (set_point_idx, str(tank_set_point)), 0, False)]
        rc = publish.multiple(msgs, hostname="192.168.2.31", port=1883, client_id="pyIntesisHome")
        print(today.strftime("%Y-%m-%d %H:%M:%S: ") + "Publish: %s" % (rc))

if __name__ == "__main__":
    main()

Hope it would be useful

mvveelen commented 5 years ago

Hi, thanks. Can you explain a bit more on how you use this? Do you use it in Domoticz? How exactly?

gianfrdp commented 5 years ago

Hello, I have a Panasonic Aquarea Heat Pump connected to a IntesisHome box. I modified a little bit pyIntesisHome code to be compatible with Aquarea https://github.com/gianfrdp/pyIntesisHome.

Using cron, I execute this script every 5 minutes. This script reads some values from IntesisHome and sends them to Domoticz using MQTT plugin and mosquitto ("domoticz/in" topic). In particular, I created 2 devices attached to a dummy hw (idx 18 and 40) for Domestic Hot Water tank temperature and SetPoint. It uses paho mqtt library. My domoitcz and mqtt server has 192.168.2.31 ip address.

*/5 * * * *     www-data        /usr/local/bin/dhw_aquarea.py

First of all, connects to IntesisHome using login/password aquarea = IntesisHome(username, password) Then read all IntesisHome values aquarea.poll_status() Then gets some single values using my IntesisHome device id (idd) (you can find it on html pages on IntesisHome website).

tank_temp = aquarea.get_tank_temperature(idd)
tank_set_point = aquarea._get_gen_value(idd,'tank_setpoint_temperature')

I defined some specific get functions and a generic get function to read a value passing name parameter.

On domiticz log

2019-04-27 01:05:03.057  MQTT: Topic: domoticz/in, Message: {"idx":40,"nvalue":0,"svalue":"48.0"}
2019-04-27 01:05:03.159  MQTT: Topic: domoticz/in, Message: {"idx":18,"nvalue":0,"svalue":"44.0"}

on mosquitto log

1556319602: New connection from 192.168.2.31 on port 1883.
1556319602: New client connected from 192.168.2.31 as pyIntesisHome (c1, k60).
1556319602: Client pyIntesisHome disconnected.