Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A8 Ventilation control
#1
Hi all!
i need some help
my situation is:
i have ventilation system consist of:

-external air motorized valve with state sensor (in fact physical button - when valve full opened button is presed)
-two temperature sensor for external air and for internal air
-electrical heater
-three fan: first for external air, second for kitchen, third for the living room

i need minimal:
1. Switch on fans and heater (IF NEEDED) ONLY when valve is full opened
2. Switch on heater when external temperature is lower than target AND internal temperature is lower than target (it is measured after heater)
3. Switch off heater when external OR internal temperature is bigger than target
4. Switch off ALL when valve sensor is off

I made some IFTTT rules for this case - it work fine

Now i want to control and change some parameters via Home Assistant:
-Change target temperature for external air
-Change target temperature for internal air
-Manually switch on and off second and third fan
-And in any situation switch off heater and fans when valve sensor is off - it is very important for safety

in this thread i found solution how to read sensors and control output via MQTT - it is work now: https://www.kincony.com/forum/showthread.php?tid=4100

so, i have two questions:
1. How i can change target values for temperature sensors?
2. Which priority is higer - MQTT command or IFTTT rules?
  2a. What will be happen if i switch off, for example, second fan, but in IFTTT rules i have condition to switch it on? and in one moment A8 lost connection to Home Assistant?ection onnection
Reply
#2
1. How i can change target values for temperature sensors? what this means?
2. which is last command send to controller will work. becasuse two command will not work at the same time.
Reply
#3
(02-04-2024, 01:37 PM)admin Wrote: 1. How i can change target values for temperature sensors?    what this means?
2. which is last command send to controller will work. becasuse two command will not work at the same time.

1. How i can change target values for temperature sensors?    what this means?

i meen that i have some targets in IFTTT rules, for exapmle 20C on internal air
and if in some moment i want 15C of internal air - how can i do it via Home Assistant remotly?

 2. which is last command send to controller will work. becasuse two command will not work at the same time.

ok, for examle:
i can switch off second fan from Home Assistant manualy.
But in IFTTT rules i have rule to start ALL FANS 

when this rule will work again, in case of condition for this rule is OK, but fan stopped by Home Assistant manualy?

and when IFTTT rules will start work again, if connection to Home Assistant is lost?


May be i can check "is Home Assistant accesseble" and if  "YES" - do not use IFTTT rules, if "NO" - start use IFTTT rules again? Is it possible?
Reply
#4
1. MQTT command not support to check the target value. if you usually need change it, suggest config AUTOMATION by home assistant without KCS.
2.
i can switch off second fan from Home Assistant manualy.
But in IFTTT rules i have rule to start ALL FANS

-->second fan will ON when IFTTT works. if you want home assistant turn OFF, it's ok, because board will never disconnected with home assistant, will not lost with home assistant.
Reply
#5
(02-06-2024, 12:52 AM)admin Wrote: 1. MQTT command not support to check the target value. if you usually need change it, suggest config AUTOMATION by home assistant without KCS.
2.
i can switch off second fan from Home Assistant manualy.
But in IFTTT rules i have rule to start ALL FANS

-->second fan will ON when IFTTT works. if you want home assistant turn OFF, it's ok, because board will never disconnected with home assistant, will not lost with home assistant.

yes, but switch can die, HomeAssistant server can die or some thing else can die...

ok, i'll try make IFTTT rules using one of input as "HomeAssistant accesible"  trigger, thank you
Reply
#6
ok, good idea.
Reply
#7
(02-07-2024, 12:34 AM)admin Wrote: ok, good idea.

Hi! so, i have solution - it is works for me.

I use another ESP8266 to ping HomeAssistant and if it accessible i can switch on one of Digital Inputs.

Here is source for Arduino IDE 1.8 (i tryed to do it on Arduino IDE 2.x but it's failed):


 
Code:
/*
   This example show how to ping a remote machine using it's hostname
   Based on ESP8266-ping project

   https://github.com/bluemurder/esp8266-ping/tree/master

   NOTE:
   bool accessible=pinger.Ping(remote_host);
   This construction ALWAYS return "true" when using IP address
   in my tests this construction return "false" only when DNS name could not be resolved, that why i use response analise to set variable HAAccesible "true" or "false" in function pinger.OnReceive([](const PingerResponse& response)
   
   NOTE2:
   this project does not work in Arduino IDE v2.x, in Arduino IDE v1.8.x it is works properly
*/

#include <Pinger.h>
#include <ESP8266WiFi.h>
extern "C"
{
#include <lwip/icmp.h> // needed for icmp packet definitions
}

// Set global to avoid object removing after setup() routine
Pinger pinger;

bool HAAccessible = false;
const char* ssid     = "stranger";
const char* password = "1234567890abcdef1234567890";
const char*remote_host = "192.168.7.6"; //Home Assistant host
int pinOut = 13; // D7 ESP8266 GPIO pin
bool stationConnected = false;
void setup()
{
  pinMode(pinOut, OUTPUT);
  // Connect to WiFi access point
  stationConnected = WiFi.begin(ssid, password);
  // Begin serial connection at 9600 baud
  Serial.begin(9600);

  // Check if connection errors
  if (!stationConnected)
  {
    Serial.println("Error, unable to connect specified WiFi network.");
  }

  // Wait connection completed
  Serial.print("Connecting to AP...");
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.print("WiFi connected \n");
}
  void loop()
  {
    //==========================
     pinger.OnReceive([](const PingerResponse& response)
  {
    if (response.ReceivedResponse)
    {
      Serial.printf(
        "Reply from %s: bytes=%d time=%lums TTL=%d\n",
        response.DestIPAddress.toString().c_str(),
        response.EchoMessageSize - sizeof(struct icmp_echo_hdr),
        response.ResponseTime,
        response.TimeToLive);
        HAAccessible=true;
    }
    else
    {
      Serial.printf("Request timed out.\n");
      HAAccessible=false;
    }

    // Return true to continue the ping sequence.
    // If current event returns false, the ping sequence is interrupted.
    return true;
  });
 
  pinger.OnEnd([](const PingerResponse& response)
  {
    // Evaluate lost packet percentage
    float loss = 100;
    if(response.TotalReceivedResponses > 0)
    {
      loss = (response.TotalSentRequests - response.TotalReceivedResponses) * 100 / response.TotalSentRequests;
    }
   
    // Print packet trip data
    Serial.printf(
      "Ping statistics for %s:\n",
      response.DestIPAddress.toString().c_str());
    Serial.printf(
      "    Packets: Sent = %lu, Received = %lu, Lost = %lu (%.2f%% loss),\n",
      response.TotalSentRequests,
      response.TotalReceivedResponses,
      response.TotalSentRequests - response.TotalReceivedResponses,
      loss);

    // Print time information
    if(response.TotalReceivedResponses > 0)
    {
      Serial.printf("Approximate round trip times in milli-seconds:\n");
      Serial.printf(
        "    Minimum = %lums, Maximum = %lums, Average = %.2fms\n",
        response.MinResponseTime,
        response.MaxResponseTime,
        response.AvgResponseTime);
    }
   
    // Print host data
    Serial.printf("Destination host data:\n");
    Serial.printf(
      "    IP address: %s\n",
      response.DestIPAddress.toString().c_str());
    if(response.DestMacAddress != nullptr)
    {
      Serial.printf(
        "    MAC address: " MACSTR "\n",
        MAC2STR(response.DestMacAddress->addr));
    }
    if(response.DestHostname != "")
    {
      Serial.printf(
        "    DNS name: %s\n",
        response.DestHostname.c_str());
    }

    return true;
  });
  //================================================
   
    while (WiFi.status() == WL_CONNECTED)
    {
      pinger.Ping(remote_host);
      Serial.println(HAAccessible);
      if (HAAccessible==false)
      {
         digitalWrite(pinOut, LOW);
        Serial.println("HA NOT Accessible.");
        delay (10000);
      }
      else
      {
        digitalWrite(pinOut, HIGH);
        Serial.println("HA Accessible.");
        delay (10000);
      }
    }
     digitalWrite(pinOut, LOW);
     HAAccessible=false;
      Serial.println("HA NOT Accessible because WiFi disconnected.");
     
      //reconnect to wi-fi;
      stationConnected = WiFi.begin(ssid, password);
      // Check if connection errors
      if (!stationConnected)
      {
        Serial.println("Error, unable to connect specified WiFi network.");
      }

      // Wait connection completed
      Serial.print("Reconnecting to AP...");
      while (WiFi.status() != WL_CONNECTED)
      {
        delay(500);
        Serial.print(".");
      }
      Serial.print("WiFi connected \n");

  }

Now, when HA accessible relays 1-4 is switching on, and when HA not accessible - switching off.
It works when WiFi failed (when WiFi restored it will be reconected)
It works when HA disconnected from LAN


Attached Files Image(s)
           
Reply
#8
ok, good.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)