General Discussion

A place to talk about whatever you want

163 Topics 1.6k Posts
  • Lua - Code to encrypt / decrypt with AES 128 CBC

    Unsolved
    27
    0 Votes
    27 Posts
    4k Views

    Thanks @akbooer - you’re so right i cant believe i missed that, I’m supposed to decode, not encode ! Doh !!

    FYI - Here’s the source.. https://github.com/florianholzapfel/panasonic-viera/issues/9#issuecomment-476919658

    How did the rest look ? Here’s my Lua inline with the source.

    -- import binascii -- import base64 -- import hmac, hashlib -- from Crypto.Cipher import AES local bit = require("bit") local mime = require("mime") local binascii = require("binascii") -- # Example challenge (which is our IV) -- iv = base64.b64decode("mUQdS7/RyJTMsiojPz9i1Q==") local challenge_key = "iL9XqQOMfkFWz2rvh0Xm+w==" local challenge_Key_unb64 = mime.unb64(challenge_key) print (challenge_Key_unb64) -- # Get character codes from IV bytes -- iv_vals = [ord(c) for c in iv] -- # Initialise key character codes array -- key_vals = [0] * 16 -- # Derive key from IV -- i = 0 -- while i < 16: -- key_vals[i] = ~iv_vals[i + 3] & 0xFF -- key_vals[i + 1] = ~iv_vals[i + 2] & 0xFF -- key_vals[i + 2] = ~iv_vals[i + 1] & 0xFF -- key_vals[i + 3] = ~iv_vals[i] & 0xFF -- i += 4 -- # Convert our key character codes to bytes -- key = ''.join(chr(c) for c in key_vals) local challenge_Key_unb64 = "ˆ¿W©Œ~AVÏjï‡Eæû" local challengekey_vals = { challenge_Key_unb64:byte(1, -1) } local key_vals = {} for i = 1, 16, 4 do key_vals[ i ] = bit.band(bit.bnot(challengekey_vals[ i + 3 ]), 0xFF) key_vals[ i + 1 ] = bit.band(bit.bnot(challengekey_vals[ i + 2 ]), 0xFF) key_vals[ i + 2 ] = bit.band(bit.bnot(challengekey_vals[ i + 1 ]), 0xFF) key_vals[ i + 3 ] = bit.band(bit.bnot(challengekey_vals[ i ]), 0xFF) end local key = string.char(unpack(key_vals)) print(key) -- "V¨@w¾sü•0©ºx " -- # Initialise HMAC key mask (taken from libtvconnect.so) -- hmac_key_mask_vals = [ord(c) for c in binascii.unhexlify("15C95AC2B08AA7EB4E228F811E34D04FA54BA7DCAC9879FA8ACDA3FC244F3854")] -- # Initialise HMAC key character codes array -- hmac_vals = [0] * 32 -- # Calculate HMAC key using HMAC key mask and IV -- i = 0 -- while i < 32: -- hmac_vals[i] = hmac_key_mask_vals[i] ^ iv_vals[(i + 2) & 0xF] -- hmac_vals[i + 1] = hmac_key_mask_vals[i + 1] ^ iv_vals[(i + 3) & 0xF] -- hmac_vals[i + 2] = hmac_key_mask_vals[i + 2] ^ iv_vals[i & 0xF] -- hmac_vals[i + 3] = hmac_key_mask_vals[i + 3] ^ iv_vals[(i + 1) & 0xF] -- i += 4 -- # Convert our HMAC key character codes to bytes -- hmac_key = ''.join(chr(c) for c in hmac_vals) local challenge_Key_unb64 = "ˆ¿W©Œ~AVÏjï‡Eæû" local challengekey_vals = { challenge_Key_unb64:byte(1, -1) } local hmac_key_mask = binascii.unhexlify('15C95AC2B08AA7EB4E228F811E34D04FA54BA7DCAC9879FA8ACDA3FC244F3854') local hmac_key_mask_vals = { hmac_key_mask:byte(1, -1) } local hmac_vals = {} for i = 1, 32, 4 do hmac_vals[i] = bit.bxor(hmac_key_mask_vals[ i ], challengekey_vals[ bit.band(i + 1, 0xF) + 1 ]) hmac_vals[i+1] = bit.bxor(hmac_key_mask_vals[ i + 1 ], challengekey_vals[ bit.band(i + 2, 0xF) + 1 ]) hmac_vals[i+2] = bit.bxor(hmac_key_mask_vals[ i + 2 ], challengekey_vals[ bit.band(i - 1, 0xF) + 1 ]) hmac_vals[i+3] = bit.bxor(hmac_key_mask_vals[ i + 3 ], challengekey_vals[ bit.band(i, 0xF) + 1 ]) end local hmac_key = string.char(unpack(hmac_vals)) print(hmac_key) --"B`Ò}Îˤg$ÍÙNøÏWòâ/cÒÙzvà"õ3´¿"" -- # This is our plaintext SOAP argument for the pin code shown on the TV -- authinfo = "<X_PinCode>4410</X_PinCode>" -- # First 12 bytes are randomised, let's just set them to 0 because it doesn't matter -- payload = "000000000000" -- # The next 4 bytes contain the plaintext (SOAP arg) length in big endian -- n = len(authinfo) -- payload += chr(n >> 24) -- payload += chr((n >> 16) & 0xFF) -- payload += chr((n >> 8) & 0xFF) -- payload += chr(n & 0xFF) -- # Now we concatenate our payload, which is starting at byte 17 of the payload -- payload += authinfo local payload = '000000000000' -- First 12 bytes are randomised local pincode = "<X_PinCode>1234</X_PinCode>" -- Next 4 bytes are from the pincode prompted by the TV n = #pincode payload = payload .. string.char(bit.band(bit.rshift(n, 24), 0xFF)) payload = payload .. string.char(bit.band(bit.rshift(n, 16), 0xFF)) payload = payload .. string.char(bit.band(bit.rshift(n, 8), 0xFF)) payload = payload .. string.char(bit.band(n, 0xFF)) payload = payload .. pincode local iv = payload print(iv) -- "0000000000001234" -- # Let's encrypt it with AES-CBC! We need to make sure we pad it to a multiple of 16 bytes beforehand -- aes = AES.new(key, AES.MODE_CBC, iv) -- ciphertext = aes.encrypt(pad(payload)) -- # Calculate the HMAC-SHA-256 signature of our encrypted payload -- sig = hmac.new(hmac_key, ciphertext, hashlib.sha256).digest() -- # Concatenate the HMAC signature to the encrypted payload and base64 encode it, and we're done! -- encrypted_payload = base64.b64encode(ciphertext + sig)

    Still the AES/CBC bit to get working, but hopefully this is progress..

  • Seeking experts for implementing Modbus TCP

    Solved
    9
    0 Votes
    9 Posts
    631 Views

    OK, after trying a few solutions a finally ended up with Home Assistant as a Hyper-V guest on my Windows server.
    First I evaluated this by Emilv2 but it did not fit my needs and wasn't very stable.
    The best option by far was this for Huawei inverters, I even tweaked the polling frequency down to 10s to have "realtime" data matching my ESP8266 hooked up to my electricity meter sending data every 10s.
    Unfortunately HASS was not able to connect to openLuup broker so I enabled the HASS controller for MSR and echo the newly created sensors to openLuup.
    I then wrote a MQTT handler for openLuup to set appropriate variables and do some math comparing electricity use and production and edited Historian to keep those for Grafana.

    Been running it for almost 2 days now without any issues.

    Some of the HASS sensors:
    hass.PNG

    openLuup variables:
    solar.PNG

    Grafana: (sorry for Swedish)
    chart.PNG sum.PNG

    This was a fun project and thanks for pointing me in the right direction!

  • 0 Votes
    5 Posts
    337 Views

    @tunnus said in http relay activate with username and password authentication:

    @destination what if you just try that curl command from the command line (without os.execute)? Just to narrow down what is working and what's not.

    No luck

  • Vera Secure usage without mios

    Unsolved
    5
    0 Votes
    5 Posts
    386 Views

    @tunnus said in Vera Secure usage without mios:

    @destination A bit late now, but you haven't heard about decoupling? No need for Vera/Ezlo servers...

    I haven't heard about decoupling, Thank you, i will search about it.

  • An electricians or wiring experts here?

    Unsolved
    9
    0 Votes
    9 Posts
    366 Views

    @akbooer I agree. My new house has them everywhere and it’s useful to use them as scene controllers as well (long press to dim, double click
    to sync levels, etc)

  • Looking for ideas on how to implement an automation.

    Solved
    17
    0 Votes
    17 Posts
    703 Views

    Thanks, at 4 for $15, I can replace them cheap.

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Is Hubitat to HA Bridge possible?

    Solved
    8
    1 Votes
    8 Posts
    405 Views

    @droy you could definitely call MSR http endpoint to achieve the same result. At this point, MSR will perform the call for you.

  • New Developer - What I should know/do ? (Vera/OpenLuup)

    Unsolved
    1
    0 Votes
    1 Posts
    140 Views
    No one has replied
  • New to Smart Home

    Unsolved
    3
    0 Votes
    3 Posts
    223 Views

    I'll definitely start with Home Assistant (or OpenHab, if you want to keep Java) and EspHome/Tasmota, in your case.Don't start from scratch.

    Tasmota and EspHome are two firmware quite popular in the market, and you'd flash them on microcontrollers and access sensors. Look at both before choosing. I prefer Tasmota, but only because that's what I know better.

    After you'll be set, you'd always add anything you want to the mix. I'm a C# dev and part of my logic runs inside a custom made applications, that's glueing different systems together. Take a look at Multi System Reactor as well, since you'll soon discover that Home Assistant lacks in terms of a powerful automation engine. Good luck!

  • Amazon Alexa hosts

    Unsolved
    1
    0 Votes
    1 Posts
    120 Views
    No one has replied
  • Merry Christmas/Happy Holidays

    15
    8 Votes
    15 Posts
    558 Views

    Happy holidays everyone!

  • Very newbie man looking for help

    Unsolved
    4
    0 Votes
    4 Posts
    228 Views

    OK so three things here:

    The Qubino. Sadly I have no idea how well supported that device is on Vera. Many devices that Vera claim to support do not really work very well. It's possible that you might be able to modify the properties of the device to make it work better, but I'm afraid I have no idea where to start. SSH is possible. I would expect this is still the way to do it:
    http://wiki.micasaverde.com/index.php/Logon_Vera_SSH OpenLuup is an Open source home automation system that is similar to Vera but much much better:
    GitHub - akbooer/openLuup: a pure-Lua open-source emulation of the Vera Luup environment GitHub - akbooer/openLuup: a pure-Lua open-source emulation of the Vera Luup environment

    a pure-Lua open-source emulation of the Vera Luup environment - akbooer/openLuup

    Many of us are on this forum because we were banned from the Vera forum for daring to challenge the approach taken by Melih. So far we seem to have been correct. Vera is a dead end and will very soon be un-supported

    Good luck!

    C

  • Help please with Node-Red "Lost connection to server"

    Unsolved
    3
    0 Votes
    3 Posts
    2k Views

    I've now powered that Tuya light back ON again so it is reachable on the WLAN and now I am able to update the nodes OK and then I rebooted the Linux box. Now the "Lost connection to server, reconnecting..." message has stopped appearing. So seems related to this Tuya node / light.

    I then powered OFF the Tuya light again and fingers crossed the "Lost connection to server, reconnecting..." message still hasn't come back, so I think managing to update the Tuya node may have fixed it. I will keep an eye on it.

  • Goodbye Brothers in crime!

    Unsolved
    5
    4 Votes
    5 Posts
    297 Views

    Shouldn't this topic be set to "SOLVED"? 😉 Good luck with Hass, and not in the ironic way.

  • Re-number on OpenLuup

    Solved
    4
    0 Votes
    4 Posts
    227 Views

    @toggledbits said in Re-number on OpenLuup:

    @catmanv2 if you're using the Reactor plug in, there's a device replacement tool on the tools menu that will appear when the failed device is deleted.

    Well I've just replaced the coffee grinder so normal service should be resumed shortly

    @kfxo said in Re-number on OpenLuup:

    Is it marked as failed in z-wave (z-way?) server? If you can reset the device without excluding it, I think you can use the replace failed node operation on the z-way server control section.

    It is marked as failed indeed.

    I was distracted and this post wasn't sent. I couldn't remove it from z-wave as it was waiting on an interview.

    It re-added fine as a new device and I've just edited Reactor manually.

    Cheers

    C

  • "kinda smart" switch to put behind a normal light switch

    Solved
    18
    0 Votes
    18 Posts
    719 Views

    @elcid CDO. It's like OCD but the letters are in the right order....

  • Bluetooth Control - Vera / Openluup

    Unsolved
    3
    0 Votes
    3 Posts
    251 Views

    I have a few really nice Xiaomi temperature and humidity sensors reporting over BLE to a Tasmota ESP32, as described in this thread. The ESP is then connected to my OpenLuup with Mqtt.

  • Occupancy - What are people using to check?

    Unsolved
    20
    0 Votes
    20 Posts
    648 Views

    Hi all,

    In the process of doing this, I’ve created a number of occupancy check scripts, each one of them is currently it’s own module (i think that’s the correct term)?

    xxoccupancy-motion.lua xxoccupancy-sonos.lua xxoccupancy-lights.lua xxoccupancy-tvs.lua

    I’ve done this to make each one manageable, with each one ultimately running a global function that will return either true or false if the occupancy criteria check is meet (true for no activity, false for recent activity)

    Although saying that, I’m probably going to make the ‘lights’ one the target now, , so if no motion, tvs or sonos are found in use, (thus all true) then run the other one, to turn off all known lights.

    Is that a good approach, or would dofile() be better, or should I simply put them all to one ‘module’ ? How would you approach doing multiple assessment/checks ?

  • Z-Wave Classes & Commands

    Unsolved
    8
    0 Votes
    8 Posts
    636 Views

    At this stage, probably not, just for the lack of consistency. The issues:

    Vera, we know, keeps the data in state variables, and we get what we get. You can get that today -- just look at the attribute on the entity in MSR and see as much information as it could publish. On a Vera ZWave device, look for x_vera_svc_micasaverde_com_ZWaveDevice1.VariablesGet. On Hass, not only does the API not tell you what integration drives an entity, but even if you forced that association by declaring the ZWave service, the service itself doesn't publish any attributes/data from the integration through the API. So the configuration variables aren't visible at all. Nor is the device's manufacturer info, model number, or even its ZWave node ID. Mind you, Hass has all of this information, it must in order to function, it just doesn't publish any of it through its APIs. On Hubitat, pretty much the same story as Hass: the API doesn't tell you what driver supplies the device, so you don't even know it's ZWave, and there's no data available attached to the device that's published through the API related to ZWave, anyway. On eZLO, they do identify the device by its parent "protocol" (zwave), and give you the ZWave node ID and a couple of flags, but no other useful information that I've seen. There aren't even API commands available for single-node things like poll a node or set a config value, only network-wide commands for things like start/stop inclusion or reset the Zwave chip and delete the entire network (i.e. not things you usually want to do in an automation). Since I'm probably the only person who cares if those other things exist and I'm persona non grata over there, they're probably not getting done any time soon, whether I report them or not. I haven't used any devices on my eZLO system that have configuration parameters, so I can't tell if or how it publishes those. If someone has included on their eZLO system a device that normally uses configuration parameters, like an Aeotec Multisensor, etc., please send me via PM your logs/ezlo_data_list.json file. I'd love to see if it has anything.

    Very low on my priorities (particularly with the big changes to the core/Engine of late) has been direct integration with ZWave-JS. That would expose all the right information, I'm sure. But that's really no small task, and in essence, transforms MSR from an automation tool into the realm of being a hub itself. Maybe that's not bad.

Recent Topics