space-state

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
space-state [2020/09/07 13:18]
jhaand use compressed image tasmota.bin.gz
space-state [2021/04/06 16:00] (current)
harm
Line 1: Line 1:
 ====== Space state ====== ====== Space state ======
-The Space state is the big switch at the entrance of our hackerspace. It allows you to activate the space and make this also  known on the internet. The whole mechanism works via three parts. The actual switch, middleware and devices. The switch poses as input mechanism on the actual state of the space. (hence the name space state) The middle ware changes some things based on the input. The devices light up or turn on when the space state is active. +The Space state is the big switch at the entrance of our hackerspace. It allows you to activate the space and make this also  known on the internet. The whole mechanism works via three parts. The actual switch, middleware and devices. The switch poses as input mechanism on the actual state of the space. (hence the name space state) The middleware changes some things based on the input. The devices light up or turn on when the space state is active. 
  
 ===== The switch ===== ===== The switch =====
-The big switch tells our main server Hitchcock that the space is open. The switch connects to a little PCB. The PCB has some LEDs, level shifting and an ESP32 NodeMCU. The NodeMCU runs a script in Micropython. You can find the latest version of the Space state switch in our gitlab archive. Or ask jaand for more information. +The big switch tells our homeassistant that the space is open. The switch connects to a little PCB. The PCB has some LEDs, level shifting and an ESP32 NodeMCU. The NodeMCU runs a script in Micropython. You can find the latest version of the Space state switch in our gitlab archive. Or ask jaand for more information. 
  
 {{ ::space_state_switch.jpg?400 |}} {{ ::space_state_switch.jpg?400 |}}
  
-The script calls a php script with a HTTP POST request to inform our server on the current state of the switch.  +The script calls a homeassistant webhook to inform it when state of the switch changesThe new state is passed as payload data to the webhook.
-In order to switch on the devices in the space, the NodeMCU will do MQTT calls to all the devices+
  
 The NodeMCU does a DHCP request using the hostname spacestate.  The NodeMCU does a DHCP request using the hostname spacestate. 
Line 24: Line 23:
  
 ===== Middleware ===== ===== Middleware =====
-Currently a php script on our signal server is on the receiving end. The script will modify the [[https://spaceapi.tdvenlo.nl/spaceapi.json|spaceapi.json]] setting the value for "open" to either true or false+Homeassistant is setup as middleware. Based on the triggers received via the webhook from the ESP, homeassistant can perform a variety of automations.
  
-The source code is also in the git archive for the space state +Currently it will modify the [[https://spaceapi.tdvenlo.nl/spaceapi.json|spaceapi.json]] setting the value for "open" to either true or false depending on the payload receivedIt will also submit MQTT messages to all devices to poweron/off.
- +
-Switching the devices works via MQTTTherefore the NodeMCU and the devices need to know the MQTT server on our networkFrom there HomeAssistant will register the switching events and handle the rest+
  
 ===== Devices ===== ===== Devices =====
Line 41: Line 38:
   * Spacemap   * Spacemap
    
-These devices connect to wifi enabled relays that will run the Tasmota firmware. Our HomeAssitant service will control the wifi relays. +These devices are powered via wifi enabled relays that run the Tasmota firmware. Our HomeAssistant service will control the wifi relays. 
  
 ==== Wifi relays ==== ==== Wifi relays ====
-The devices switch via wifi relays. These relays connect to the regular power and switch via commands given via our 2.4GHz wifi. You can find the relays in the grey 4-way wall sockets. They're in raised wall mounted wall sockets type: ABB HAF 1640. Currently we use 2 different relays: Shelly1 and Sonoff mini.  +The devices switch via wifi relays. These relays connect to the regular power and switch via commands given via our 2.4GHz wifi. You can find the relays in the grey 4-way wall sockets. They're in raised wall mounted wall sockets type: ABB HAF 1640. Currently we use 2 different relays: Shelly1 and Sonoff mini. All relays communicate to homeassistant via MQTT. Each device listens on it's own MQTT topic which is autodiscovered by homeassistant.
-Given all the features and firmware the we run, I would suggest that future expansions use the Sonoff mini with the Tasmota firmware+
  
 === Tasmota firmware === === Tasmota firmware ===
Line 57: Line 53:
 </code> </code>
  
-You can switch these on and off via Home assitant or via HTTP. This is how you do it via HTTP:+You can switch these on and off via Homeassistant/MQTT or directly to the device via HTTP. This is how you do it via HTTP:
 <code> <code>
 #!/bin/bash #!/bin/bash
Line 71: Line 67:
 If you want to integrate Tasmota switches with Home Assistant you need to do the following 2 actions: If you want to integrate Tasmota switches with Home Assistant you need to do the following 2 actions:
   * Issue "SetOption19 1" in the console   * Issue "SetOption19 1" in the console
-  * install the tasmota.bin.gz compressed image on the wifi relay if you want to do an OTA upgrade.+  * Install the tasmota.bin.gz compressed image on the wifi relay if you want to do an OTA upgrade.
   * Make MQTT setting point to our server.    * Make MQTT setting point to our server. 
  
  • space-state.txt
  • Last modified: 2021/04/06 16:00
  • by harm