Skip to content

Instantly share code, notes, and snippets.

@sarjsheff
sarjsheff / Auth.js
Last active June 7, 2020 12:38
Authorization react + socket.io
import React, { useState, useEffect } from "react";
import * as io from "socket.io-client";
const socket = io();
function Auth() {
const [auth, setAuth] = useState(false);
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [name, setName] = useState("");
@sarjsheff
sarjsheff / tasmota-to-gun.js
Created June 7, 2020 06:23
Store tasmota mqtt events in GUN database.
var Gun = require('gun');
const gun = Gun("http://localhost:8888/gun");
gun.get("switches").map().on(function(v, name) {
console.log(name, v.status, v.power || "ON", v.temp || "?");
})
var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://localhost', {
username: "sonoff",